* { box-sizing: border-box; }
:root {
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-light: #e6fbf8;
}
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f4f6f8;
  color: #1a1f27;
}
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
}
.login-box {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  width: 340px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-logo { display: block; height: 48px; margin: 0 auto 14px; }
.login-box h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
.login-box .subtitle { margin: 0 0 24px; color: #6b7280; font-size: 13px; text-align: center; }
.login-box label { display: block; margin: 12px 0 4px; font-size: 13px; font-weight: 600; }
.login-box input {
  width: 100%; padding: 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px;
}
.login-box button, button, .btn-small { cursor: pointer; }
.login-box button {
  margin-top: 20px; width: 100%; padding: 11px; background: var(--teal); color: #fff;
  border: none; border-radius: 6px; font-size: 14px; font-weight: 600;
}
.login-box button:hover { background: var(--teal-dark); }

body { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: #ffffff;
  color: #1f2937;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  border-right: 1px solid #eef0f2;
}
.sidebar .brand {
  font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 10px;
  padding: 0 20px 18px; border-bottom: 1px solid #eef0f2; color: #111827;
}
.brand-logo { height: 28px; width: auto; }

.active-device {
  margin: 16px 20px; padding: 10px 12px; background: var(--teal-light); border-radius: 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.active-device .label { font-size: 10px; text-transform: uppercase; color: var(--teal-dark); letter-spacing: 0.05em; }
.active-device .value { font-size: 13px; font-weight: 600; color: #0b3b36; }
.conn-status { display: flex; align-items: center; font-size: 11px; color: #6b7280; margin-top: 4px; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; margin-right: 5px; flex-shrink: 0; }
.conn-dot.conn-online { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,0.15); }
.conn-dot.conn-offline { background: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,0.15); }

.nav-links { display: flex; flex-direction: column; margin-top: 6px; flex: 1; }
.nav-links a {
  color: #4b5563; text-decoration: none; font-size: 14px; padding: 11px 20px;
  border-left: 3px solid transparent;
}
.nav-links a:hover { color: #111827; background: #f4fbfa; }
.nav-links a.active { color: var(--teal-dark); background: var(--teal-light); border-left-color: var(--teal); font-weight: 600; }

.nav-user { padding: 16px 20px 0; border-top: 1px solid #eef0f2; margin-top: 12px; }
.nav-user .who { font-size: 13px; color: #1f2937; margin-bottom: 4px; }
.nav-user .who .role { color: #9ca3af; margin-left: 4px; }
.nav-user a { color: #dc2626; text-decoration: none; font-size: 13px; }

.note { font-size: 12px; color: #6b7280; background: #f3f4f6; padding: 10px 14px; border-radius: 6px; }

.main { flex: 1; max-width: 1150px; margin: 30px auto; padding: 0 30px; width: 100%; }
.main h2 { margin-bottom: 6px; }

.alert { padding: 12px 16px; border-radius: 6px; margin: 14px 0; font-size: 14px; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

.add-box { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px 18px; margin: 16px 0; }
.add-box summary { cursor: pointer; font-weight: 600; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.inline-form input[type=text], .inline-form input[type=password], .inline-form select {
  padding: 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px;
}
.inline-form button {
  padding: 8px 14px; background: var(--teal); color: #fff; border: none; border-radius: 6px; font-size: 13px; font-weight: 600;
}
.inline-form button:hover { background: var(--teal-dark); }

.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.data-table th, .data-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid #f0f1f3; font-size: 14px; }
.data-table th { background: #f9fafb; font-size: 12px; text-transform: uppercase; color: #6b7280; }
.data-table .actions { white-space: nowrap; }
.action-row { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.action-row .inline-form { margin-top: 0; }
.btn-edit { color: #1a1f27; }
.btn-disable { background: #fff7ed; border-color: #fb923c; color: #c2410c; }
.btn-disable:hover { background: #ffedd5; }
.btn-enable { background: #f0fdf4; border-color: #4ade80; color: #15803d; }
.btn-enable:hover { background: #dcfce7; }
.muted-text { color: #9ca3af; font-size: 13px; }
.data-table .empty { text-align: center; color: #9ca3af; padding: 30px; }

.badge { padding: 3px 9px; border-radius: 100px; font-size: 12px; font-weight: 600; }
.badge-on { background: var(--teal-light); color: var(--teal-dark); }
.badge-off { background: #fee2e2; color: #991b1b; }
.badge-live { background: #dbeafe; color: #1e40af; }

.btn-small { padding: 6px 10px; border: 1px solid #d1d5db; background: #fff; border-radius: 6px; font-size: 12px; }
.btn-small:hover { background: #f3f4f6; }
.btn-danger { color: #dc2626; border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }

.info-table { border-collapse: collapse; background: #fff; margin: 14px 0; }
.info-table th, .info-table td { padding: 8px 14px; border: 1px solid #e5e7eb; text-align: left; font-size: 14px; }
.info-table th { background: #f9fafb; }

form.inline-form input[type=hidden] { display: none; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.btn-primary {
  padding: 9px 16px; background: var(--teal); color: #fff; border: none; border-radius: 6px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: var(--teal-dark); }

.inline-label { font-size: 12px; color: #6b7280; display: inline-flex; align-items: center; gap: 6px; }
.inline-label input[type=date] { padding: 7px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; }
.field-optional { color: #9ca3af; font-weight: 400; }

.pw-mask { display: inline-flex; align-items: center; gap: 6px; font-family: monospace; }
.pw-toggle { border: none; background: none; cursor: pointer; font-size: 14px; padding: 2px 4px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-top: 20px; }
.card {
  background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border-left: 4px solid #9ca3af;
}
.card-value { font-size: 32px; font-weight: 700; }
.card-label { font-size: 13px; color: #6b7280; margin-top: 4px; }
.card-link { text-decoration: none; color: inherit; display: block; transition: transform 0.1s, box-shadow 0.15s; cursor: pointer; }
.card-link:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-2px); }
.card-blue { border-left-color: var(--teal); }
.card-green { border-left-color: #16a34a; }
.card-gray { border-left-color: #6b7280; }
.card-red { border-left-color: #dc2626; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5);
  align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 12px; width: 100%; max-width: 480px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3); max-height: 90vh; overflow-y: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid #eef0f2;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { border: none; background: none; font-size: 20px; cursor: pointer; color: #6b7280; line-height: 1; }
.modal-close:hover { color: #111827; }
.modal-body { padding: 20px 22px; }
.modal-body form { display: flex; flex-direction: column; gap: 14px; }
.modal-body label { font-size: 13px; font-weight: 600; color: #374151; display: flex; flex-direction: column; gap: 5px; }
.modal-body label.checkbox-label { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.modal-body label.checkbox-label input[type=checkbox] { width: auto; }
.modal-body input[type=text], .modal-body input[type=password], .modal-body input[type=date], .modal-body select {
  padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; font-weight: 400;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.btn-secondary {
  padding: 9px 16px; background: #fff; color: #374151; border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-secondary:hover { background: #f3f4f6; }

.pw-gen-row { display: flex; gap: 8px; }
.pw-gen-row input { flex: 1; }
.pw-gen-row button { white-space: nowrap; padding: 9px 12px; font-size: 12px; }
