* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #333; min-height: 100vh; line-height: 1.5; }
a { color: #1677ff; text-decoration: none; }

/* Login */
.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
.login-card { background: #fff; padding: 48px 40px; border-radius: 12px; box-shadow: 0 8px 40px rgba(0,0,0,.3); width: 400px; }
.login-card h1 { text-align: center; font-size: 24px; margin-bottom: 6px; color: #1a1a2e; letter-spacing: 1px; }
.login-card .subtitle { text-align: center; color: #999; margin-bottom: 36px; font-size: 13px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; color: #555; }
.form-group input, .form-group select { width: 100%; padding: 10px 12px; border: 1px solid #d9d9d9; border-radius: 6px; font-size: 14px; transition: border-color .2s, box-shadow .2s; background: #fff; }
.form-group input:focus, .form-group select:focus { border-color: #1677ff; outline: none; box-shadow: 0 0 0 3px rgba(22,119,255,.12); }
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 18px; border: none; border-radius: 6px; font-size: 14px; cursor: pointer; font-weight: 500; transition: all .2s; white-space: nowrap; gap: 6px; line-height: 1.4; }
.btn:hover { opacity: 0.88; transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.1); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: #1677ff; color: #fff; }
.btn-primary:hover { background: #4096ff; }
.btn-danger { background: #ff4d4f; color: #fff; }
.btn-danger:hover { background: #ff7875; }
.btn-success { background: #52c41a; color: #fff; }
.btn-success:hover { background: #73d13d; }
.btn-warning { background: #fa8c16; color: #fff; }
.btn-warning:hover { background: #ffa940; }
.btn-default { background: #fff; border: 1px solid #d9d9d9; color: #555; }
.btn-default:hover { border-color: #1677ff; color: #1677ff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: 1px; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 6px 0 0 6px; }
.btn-group .btn:last-child { border-radius: 0 6px 6px 0; }
.error-msg { color: #ff4d4f; font-size: 13px; margin-top: 6px; min-height: 20px; }

/* Layout */
.header { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.08); padding: 0 28px; display: flex; align-items: center; height: 56px; position: sticky; top: 0; z-index: 100; }
.header .logo { font-size: 18px; font-weight: 700; color: #1a1a2e; display: flex; align-items: center; gap: 10px; }
.header .logo:before { content: ''; display: inline-block; width: 32px; height: 32px; background: linear-gradient(135deg, #52c41a, #1677ff); border-radius: 8px; }
.header nav { margin-left: 44px; display: flex; gap: 4px; }
.header nav a { padding: 8px 18px; border-radius: 6px; color: #555; font-size: 14px; transition: all .2s; }
.header nav a:hover { background: #f5f5f5; color: #333; }
.header nav a.active { background: #e6f4ff; color: #1677ff; font-weight: 600; }
.header .user-info { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; color: #888; }
.container { max-width: 1240px; margin: 0 auto; padding: 24px 28px; }

/* Page title */
.page-title { font-size: 22px; font-weight: 700; color: #1a1a2e; margin-bottom: 20px; }
.page-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }

/* Cards */
.card { background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06); margin-bottom: 20px; overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid #f0f0f0; font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: space-between; }
.card-body { padding: 20px; }
.card-body.no-padding { padding: 0; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; padding: 22px 20px; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06); position: relative; overflow: hidden; transition: transform .2s, box-shadow .2s; cursor: default; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.stat-card .stat-icon { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 40px; opacity: .08; }
.stat-card .stat-value { font-size: 30px; font-weight: 700; color: #1a1a2e; line-height: 1; }
.stat-card .stat-label { font-size: 13px; color: #999; margin-top: 8px; }
.stat-card.accent-blue { border-left: 3px solid #1677ff; }
.stat-card.accent-green { border-left: 3px solid #52c41a; }
.stat-card.accent-orange { border-left: 3px solid #fa8c16; }
.stat-card.accent-red { border-left: 3px solid #ff4d4f; }
.stat-card.accent-purple { border-left: 3px solid #722ed1; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
th { background: #fafafa; font-weight: 600; color: #888; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
tr:hover td { background: #fafafa; }
td:last-child { white-space: nowrap; }
th.check-col, td.check-col { width: 40px; padding: 12px 8px; text-align: center; }
input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: #1677ff; }

/* Badge */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 500; }
.badge-success { background: #f6ffed; color: #52c41a; }
.badge-danger { background: #fff2f0; color: #ff4d4f; }
.badge-warn { background: #fffbe6; color: #d48806; }
.badge-default { background: #f5f5f5; color: #999; }
.badge-blue { background: #e6f4ff; color: #1677ff; }

/* Modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.45); z-index: 1000; justify-content: center; align-items: flex-start; padding-top: 10vh; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 10px; width: 500px; max-height: 80vh; overflow-y: auto; box-shadow: 0 12px 48px rgba(0,0,0,.2); animation: modalIn .2s ease; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-20px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header { padding: 18px 24px; border-bottom: 1px solid #f0f0f0; font-weight: 600; font-size: 16px; display: flex; justify-content: space-between; align-items: center; }
.modal-header button { background: none; border: none; font-size: 18px; cursor: pointer; color: #999; padding: 4px 8px; border-radius: 4px; }
.modal-header button:hover { background: #f0f0f0; color: #333; }
.modal-body { padding: 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid #f0f0f0; display: flex; justify-content: flex-end; gap: 10px; }

/* Utilities */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.ml-auto { margin-left: auto; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: #999; font-size: 13px; }
.text-sm { font-size: 13px; }
.fw-600 { font-weight: 600; }

/* Batch action bar */
.batch-bar { display: flex; background: #e6f4ff; border: 1px solid #91caff; border-radius: 8px; padding: 10px 16px; margin-bottom: 12px; align-items: center; gap: 12px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
.batch-bar.show { opacity: 1; pointer-events: auto; }
.batch-bar .selected-count { font-size: 13px; color: #1677ff; font-weight: 600; }
/* Pagination */
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 20px; }
.pagination .page-info { font-size: 13px; color: #888; }

/* Simulation status */
.sim-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.sim-dot.running { background: #52c41a; animation: pulse 1.5s infinite; }
.sim-dot.stopped { background: #d9d9d9; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* Alert */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.alert-warn { background: #fffbe6; border: 1px solid #ffe58f; color: #ad6800; }
.alert-info { background: #e6f4ff; border: 1px solid #91caff; color: #0958d9; }
.alert-success { background: #f6ffed; border: 1px solid #b7eb8f; color: #389e0d; }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: 8px; color: #fff; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: toastIn .3s ease; max-width: 380px; }
.toast.success { background: #52c41a; }
.toast.error { background: #ff4d4f; }
.toast.info { background: #1677ff; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; color: #ccc; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 14px; color: #999; }

/* Loading spinner */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #d9d9d9; border-top-color: #1677ff; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Device info grid */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.info-item label { display: block; font-size: 12px; color: #999; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.info-item .info-value { font-size: 15px; font-weight: 600; color: #333; }
.info-item input.info-value { border: 1px solid #d9d9d9; border-radius: 4px; padding: 6px 10px; width: 100px; font-size: 14px; }

/* Responsive */
@media (max-width: 768px) {
  .header { padding: 0 16px; }
  .header nav { margin-left: 20px; gap: 2px; }
  .header nav a { padding: 6px 10px; font-size: 13px; }
  .container { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-toolbar { flex-direction: column; align-items: flex-start; }
}
