*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-bg: #0f1f3d;
  --sidebar-hover: rgba(255,255,255,0.07);
  --sidebar-active-bg: rgba(59,130,246,0.18);
  --sidebar-active-border: #3b82f6;
  --sidebar-text: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Sidebar ── */
.sidebar {
  width: 232px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 20px 20px 18px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo span {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--sidebar-text);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 3px;
  margin-left: 28px;
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-section {
  padding: 12px 20px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 450;
  border-left: 3px solid transparent;
  transition: background 0.1s, color 0.1s;
}

.nav-link:hover { background: var(--sidebar-hover); color: #fff; }

.nav-link.active {
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active-border);
  color: #fff;
  font-weight: 600;
}

.nav-icon { width: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  font-size: 13px;
  color: var(--sidebar-text);
  margin-bottom: 10px;
}

.sidebar-user strong {
  display: block;
  color: #fff;
  font-size: 13.5px;
  margin-bottom: 1px;
}

/* ── Main ── */
.main {
  margin-left: 232px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 17px; font-weight: 700; color: var(--text); }

.content { padding: 28px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 24px;
  margin-bottom: 22px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

/* ── Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}

td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.12s, box-shadow 0.12s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f8fafc; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 5px; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: auto;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

textarea.form-control { resize: vertical; min-height: 72px; font-family: inherit; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

/* ── Alerts ── */
.alert {
  padding: 11px 14px;
  border-radius: 7px;
  margin-bottom: 18px;
  font-size: 13.5px;
}

.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-active { background: #dcfce7; color: #15803d; }
.badge-out_of_service { background: #fef3c7; color: #92400e; }
.badge-decommissioned { background: #fee2e2; color: #991b1b; }

/* ── Breadcrumb ── */
.breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ── Action row ── */
.action-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── Login ── */
.login-page {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
}

.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.login-logo p { font-size: 13px; color: var(--text-muted); }

/* ── Touch Log ── */
.log-entry {
  border-left: 3px solid var(--primary);
  padding: 14px 18px;
  background: #fff;
  border-radius: 0 8px 8px 0;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-left-color: var(--primary);
}

.log-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.log-entry-type { font-weight: 700; font-size: 14px; }
.log-entry-meta { font-size: 12px; color: var(--text-muted); text-align: right; line-height: 1.5; }
.log-entry-desc { font-size: 13.5px; color: var(--text); margin-bottom: 6px; white-space: pre-line; }
.log-entry-parts { font-size: 12.5px; color: var(--text-muted); }

/* ── Dashboard recent ── */
.recent-list { list-style: none; }

.recent-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.recent-item:last-child { border-bottom: none; }

.recent-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: rgba(37,99,235,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.recent-content { flex: 1; min-width: 0; }
.recent-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.recent-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Sidebar Search ── */
.sidebar-search {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 9px;
  color: rgba(255,255,255,0.35);
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px;
  padding: 7px 10px 7px 30px;
  font-size: 13px;
  color: #fff;
  outline: none;
  transition: background 0.15s, border-color 0.15s;
}

.search-input::placeholder { color: rgba(255,255,255,0.35); }

.search-input:focus {
  background: rgba(255,255,255,0.13);
  border-color: rgba(59,130,246,0.6);
}

/* ── LID copy ── */
.lid-copy:hover { opacity: 0.75; }

.lid-copied {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eff6ff;
  color: #16a34a;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 700;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.lid-copied.show { opacity: 1; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,31,61,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.modal-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .two-col { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
