:root {
  --brand: #0aa6d6;
  --primary: #087ca7;
  --primary-dark: #066382;
  --sidebar: #4f4a43;
  --ink: #17212b;
  --muted: #66717e;
  --line: #dde3e8;
  --surface: #ffffff;
  --background: #f5f7f9;
  --success: #168453;
  --warning: #a45c00;
  --danger: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(23, 33, 43, 0.06), 0 8px 24px rgba(23, 33, 43, 0.05);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
button, input, select { font: inherit; }
button, a, input, select { outline-offset: 3px; }
:focus-visible { outline: 3px solid rgba(10, 166, 214, 0.45); }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 16px; display: flex; flex-direction: column; background: var(--sidebar); color: white; }
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 22px; color: white; }
.brand:hover { color: white; }
.brand img { border-radius: 50%; background: white; }
.brand span { display: grid; line-height: 1.15; }
.brand strong { font-size: 17px; letter-spacing: 0.01em; }
.brand small { margin-top: 3px; color: #d9d4cd; }
.sidebar-nav { display: grid; gap: 4px; }
.sidebar-nav a { min-height: 42px; display: flex; align-items: center; padding: 0 12px; border-radius: 8px; color: #ebe8e3; font-weight: 600; }
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: white; }
.sidebar-nav a.active { background: var(--primary); color: white; }
.sidebar-account { margin-top: auto; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; align-items: center; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.14); }
.sidebar-account > div { min-width: 0; display: grid; }
.sidebar-account strong { overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.sidebar-account small { color: #d9d4cd; text-transform: capitalize; }
.sidebar-account form { grid-column: 2; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--brand); font-weight: 800; }
.link-button { border: 0; padding: 0; background: none; color: #d9d4cd; cursor: pointer; }
.link-button:hover { color: white; }

.main-panel { min-width: 0; }
.topbar { height: 80px; padding: 0 32px; display: flex; align-items: center; gap: 18px; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); }
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -0.025em; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.health-pill { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: white; font-weight: 650; }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: #20a66a; box-shadow: 0 0 0 4px rgba(32,166,106,.12); }
.mobile-menu { display: none; border: 0; background: none; font-size: 24px; }
.page-content { max-width: 1500px; padding: 28px 32px 48px; margin: 0 auto; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.metric-grid-small { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-card { min-height: 142px; padding: 20px; display: flex; flex-direction: column; border: 1px solid var(--line); border-top: 3px solid var(--primary); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric-card > span { color: var(--muted); font-weight: 650; }
.metric-card strong { margin: 9px 0 7px; font-size: 34px; letter-spacing: -0.04em; }
.metric-card a, .metric-card small { margin-top: auto; color: var(--muted); }
.metric-card a:hover { color: var(--primary); }
.metric-card.metric-attention { border-top-color: #e19024; }

.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.panel { margin-bottom: 20px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.panel-header h2 { margin: 0; font-size: 18px; }
.panel-header p { margin: 5px 0 0; color: var(--muted); }
.count-label { padding: 5px 9px; border-radius: 999px; background: #eef3f6; color: var(--muted); white-space: nowrap; font-weight: 650; }
.text-link { font-weight: 650; white-space: nowrap; }
.split-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

.attention-list { display: grid; gap: 10px; }
.attention-item { min-height: 65px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-radius: 9px; background: #f7f9fa; color: var(--ink); }
.attention-item:hover { background: #eef4f6; color: var(--ink); }
.attention-item div { display: grid; gap: 3px; }
.attention-item span { color: var(--muted); }
.attention-item b { font-size: 20px; }
.activity-list, .file-list, .inspection-list { padding: 0; margin: 0; list-style: none; }
.activity-list li { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid #edf0f2; }
.activity-list li:last-child { border-bottom: 0; }
.activity-list li > div { display: grid; gap: 3px; }
.activity-list small { color: var(--muted); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #94a0ab; }
.status-dot.status-completed { background: var(--success); }
.status-dot.status-failed { background: var(--danger); }
.status-dot.status-running { background: #d48419; }
.status-badge { display: inline-flex; align-items: center; width: fit-content; padding: 4px 8px; border-radius: 999px; background: #eef1f3; color: #53606b; font-size: 12px; font-weight: 750; text-transform: capitalize; }
.status-success, .status-completed { background: #e3f5ec; color: #0b7044; }
.status-warning, .status-running, .status-pending { background: #fff0d8; color: #8b4a00; }
.status-failed, .status-disabled { background: #fde8e7; color: #9c2118; }

.notice { margin-bottom: 20px; padding: 14px 16px; border: 1px solid; border-radius: 10px; }
.notice-success { border-color: #9bd5ba; background: #ecfaf3; color: #0c6841; }
.notice-warning { border-color: #e8bd76; background: #fff7e9; color: #7a4200; }
.notice-danger { border-color: #e8a7a2; background: #fff0ef; color: #8b1e16; }
.sensitive-value { margin: 10px 0 5px; display: flex; gap: 10px; align-items: center; }
.sensitive-value code { min-width: 0; padding: 9px 11px; overflow-wrap: anywhere; border: 1px solid rgba(0,0,0,.12); border-radius: 7px; background: white; color: var(--ink); }

.field { display: grid; gap: 7px; }
.field > span { font-weight: 700; }
.field small { color: var(--muted); line-height: 1.45; }
input, select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #c8d0d7; border-radius: 8px; background: white; color: var(--ink); }
input:hover, select:hover { border-color: #9daab4; }
input:focus, select:focus { border-color: var(--primary); }
.inline-form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; }
.compact-form { display: flex; gap: 7px; }
.compact-form input { width: 105px; min-height: 34px; }
.search-control { display: flex; gap: 10px; }
.search-control input { flex: 1; }

.button { min-height: 40px; padding: 8px 14px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 8px; font-weight: 750; cursor: pointer; }
.button-primary { background: var(--primary); color: white; }
.button-primary:hover { background: var(--primary-dark); color: white; }
.button-secondary { border-color: #c8d0d7; background: white; color: var(--ink); }
.button-secondary:hover { border-color: var(--primary); color: var(--primary); }
.button-warning { border-color: #e1a653; background: #fff7e9; color: #7c4300; }
.button-danger { border-color: #e2aaa5; background: #fff0ef; color: var(--danger); }
.button-small { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.button-full { width: 100%; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; letter-spacing: .025em; text-transform: uppercase; }
.data-table td { padding: 13px 12px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
.data-table tbody tr:hover { background: #fafcfd; }
.actions-cell { display: flex; flex-wrap: wrap; gap: 7px; }
.actions-cell form { margin: 0; }
.token-badge { padding: 5px 9px; border-radius: 7px; background: #eaf6fa; color: #066c91; font-weight: 800; }
.truncate { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-action { color: #44515c; }
.current-user { display: inline-block; margin-left: 7px; color: var(--primary); font-weight: 700; }
.empty-state { padding: 22px 0; color: var(--muted); text-align: center; }
.empty-hero { padding: 80px 20px; text-align: center; color: var(--muted); }
.empty-hero h2 { color: var(--ink); }

.employee-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.employee-card { padding: 18px; border: 1px solid var(--line); border-radius: 10px; }
.employee-heading { display: flex; justify-content: space-between; gap: 15px; }
.employee-heading h3 { margin: 0; }
.employee-heading p { margin: 4px 0 0; color: var(--muted); }
.details-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.details-list div { display: grid; gap: 3px; }
.details-list dt { color: var(--muted); font-size: 12px; }
.details-list dd { margin: 0; font-weight: 650; }
.employee-card h4 { margin: 15px 0 8px; }
.inspection-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid #edf0f2; }
.inspection-list li div { display: grid; gap: 2px; }
.inspection-list small { color: var(--muted); }
.file-list li { padding: 12px 0; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #edf0f2; }
.file-list li > div { display: grid; gap: 3px; }
.file-list small { color: var(--muted); }

.admin-auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #e7f7fc 0, var(--background) 45%); }
.admin-auth-shell { width: min(100%, 430px); }
.admin-auth-brand { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 20px; }
.admin-auth-brand img { border-radius: 50%; background: white; box-shadow: var(--shadow); }
.admin-auth-brand div { display: grid; }
.admin-auth-brand strong { font-size: 23px; }
.admin-auth-brand span { color: var(--muted); }
.auth-card { padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 7px; font-size: 24px; }
.auth-intro { margin: 0 0 22px; color: var(--muted); line-height: 1.5; }
.auth-card form { display: grid; gap: 16px; }
.auth-links { margin-top: 18px; text-align: center; }
.admin-auth-footer { text-align: center; color: var(--muted); font-size: 12px; }
.error-card { text-align: center; }
.error-code { display: block; color: var(--brand); font-size: 44px; font-weight: 850; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid, .split-actions { grid-template-columns: 1fr; }
  .employee-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .admin-shell { display: block; }
  .sidebar { position: fixed; z-index: 20; width: 260px; transform: translateX(-105%); transition: transform .2s ease; }
  .nav-open .sidebar { transform: translateX(0); }
  .mobile-menu { display: block; }
  .topbar { height: 72px; padding: 0 18px; justify-content: flex-start; }
  .topbar .health-pill { margin-left: auto; font-size: 0; }
  .page-content { padding: 20px 14px 40px; }
  .metric-grid, .metric-grid-small { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .details-list { grid-template-columns: 1fr 1fr; }
  .panel { padding: 17px; }
  .search-control { display: grid; }
}
