﻿* { box-sizing: border-box; }

:root {
  --bg-0: #f4f7fb;
  --bg-1: #e9f0f8;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #142133;
  --text-muted: #516279;
  --line: #d9e3ef;
  --primary: #0f4c81;
  --primary-2: #2a7abf;
  --accent: #f4b942;
  --ok: #1f9d62;
  --warn: #d6861c;
  --danger: #c93d3d;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 14px 38px rgba(14, 35, 62, 0.08);
}

body {
  margin: 0;
  font-family: "Be Vietnam Pro", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1000px 460px at 12% -8%, #dbe9f8 0%, transparent 62%),
    radial-gradient(900px 440px at 96% 0%, #e3f0ff 0%, transparent 54%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1));
}

.hidden { display: none !important; }

.app {
  width: 100%;
  max-width: 1460px;
  margin: 0 auto;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  display: grid;
  gap: 10px;
  box-shadow: var(--shadow);
}

.login-card h1 { margin: 0; font-size: 24px; letter-spacing: -.2px; }
.login-card p { margin: 0 0 8px; color: var(--text-muted); }
.login-card label { display: grid; gap: 5px; font-size: 13px; color: #33465f; }
.login-card input { min-height: 42px; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-login {
  padding-bottom: 8px;
  margin-bottom: 2px;
  border-bottom: 1px dashed #dbe5f1;
}

.brand-logo {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  object-fit: contain;
  object-position: center;
  padding: 4px;
  border: 1px solid #d4dfeb;
  box-shadow: 0 6px 18px rgba(12, 42, 76, 0.15);
  background: #fff;
}

.brand-text { display: grid; line-height: 1.1; }
.brand-text strong {
  font-size: 15px;
  letter-spacing: .3px;
  color: #0f3f6a;
}
.brand-text span {
  font-size: 12px;
  color: #5e7290;
}

.error { color: #b00020; font-size: 13px; min-height: 18px; }

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  margin: 10px 12px 0;
  border-radius: 16px;
  border: 1px solid #25527f;
  background: linear-gradient(94deg, #0d385f, #165587 45%, #2a7abf);
  color: #fff;
  box-shadow: 0 16px 34px rgba(9, 42, 74, 0.25);
}

.top-title h1 { margin: 0 0 3px; font-size: 20px; font-weight: 700; }
.top-title p { margin: 0; opacity: .92; font-size: 13px; }

.top-actions { display: flex; gap: 8px; }

button {
  border: 1px solid transparent;
  background: var(--accent);
  color: #172231;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
button:hover { transform: translateY(-1px); filter: saturate(1.05); }
button:active { transform: translateY(0); }
button.ghost { background: #ffffff1f; color: #fff; border-color: #ffffff63; }
button.ghost-soft { background: #edf4fb; color: #173254; border-color: #d3dfed; }
button.danger { background: #d84c4c; color: #fff; border-color: #c83e3e; }

.controls {
  display: grid;
  grid-template-columns: 220px 1fr 1fr;
  gap: 10px;
  align-items: end;
  padding: 14px 20px;
  margin: 8px 12px 0;
  background: #ffffffc7;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(3px);
}

label {
  font-size: 13px;
  display: grid;
  gap: 4px;
  color: #33465f;
}

select,
input {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #c6d5e6;
  border-radius: 8px;
  background: #fff;
  color: #1b2a3d;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid #9bc5ef;
  outline-offset: 1px;
}

input[readonly] {
  background: #f0f5fb;
  color: #4c607c;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 11px 14px;
  margin: 8px 12px 0;
  border-radius: 12px;
  background: #ffffffc4;
  border: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab {
  background: #fff;
  color: #1d2e43;
  border: 1px solid #cad7e8;
  white-space: nowrap;
  flex: 0 0 auto;
}

.tab.active {
  background: linear-gradient(140deg, #0f4c81, #2a7abf);
  color: #fff;
  border-color: #0f4c81;
}

.status {
  padding: 5px 22px 10px;
  font-size: 14px;
  color: #25425f;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.dashboard-filter,
.dashboard-insight {
  margin: 0 12px 12px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding: 0 12px 14px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 7px 18px rgba(17, 40, 66, 0.06);
}
.kpi .label { font-size: 12px; color: #58708f; }
.kpi .value { font-size: 24px; font-weight: 800; margin-top: 2px; }
.kpi.kpi-neutral { background: linear-gradient(180deg,#ffffff,#f3f7ff); }
.kpi.kpi-ready { background: linear-gradient(180deg,#e9fff2,#d7f7e7); border-color: #8ddcb3; }
.kpi.kpi-using { background: linear-gradient(180deg,#eaf4ff,#d6eaff); border-color: #96c2f4; }
.kpi.kpi-moving { background: linear-gradient(180deg,#fff8e9,#ffecc7); border-color: #efc77f; }
.kpi.kpi-maintain { background: linear-gradient(180deg,#fff6ec,#ffe2bf); border-color: #efba70; }
.kpi.kpi-broken { background: linear-gradient(180deg,#ffefef,#ffd8d8); border-color: #ec9f9f; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 0 12px 18px;
}

.panel {
  background: #ffffffde;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 8px 22px rgba(16, 41, 70, 0.06);
}
.panel h2 { margin: 0 0 10px; font-size: 16px; }
.panel-note {
  margin: -2px 0 10px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.wide { grid-column: span 2; }

.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  padding: 6px 10px;
  background: #ecf3fb;
  border: 1px solid #d3e0f0;
  border-radius: 999px;
  font-size: 12px;
}

.insight {
  border-radius: 10px;
  padding: 11px 12px;
  border: 1px solid #dbe3f0;
  font-size: 14px;
}
.insight.ok { background: #ebfff3; border-color: #9fdab7; color: #165d33; }
.insight.warn { background: #fff7e8; border-color: #e6c488; color: #7b4c07; }
.insight.danger { background: #ffeded; border-color: #e6a3a3; color: #8a1111; }

.bar-list { display: grid; gap: 10px; }
.bar-row .bar-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 4px;
}
.bar-track {
  width: 100%;
  height: 11px;
  border-radius: 999px;
  background: #ebf1f8;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg,#4d79d9,#39b4dc);
}
.bar-row.tone-s-n-s-ng .bar-fill { background: linear-gradient(90deg,#1f9d62,#46d88d); }
.bar-row.tone--ang-s-d-ng .bar-fill { background: linear-gradient(90deg,#3768c7,#72a2ff); }
.bar-row.tone--ang-v-n-chuy-n .bar-fill { background: linear-gradient(90deg,#e38b08,#f6bf56); }
.bar-row.tone-b-o-tr- .bar-fill { background: linear-gradient(90deg,#d37a15,#efaa57); }
.bar-row.tone-h-h-ng .bar-fill { background: linear-gradient(90deg,#c93d3d,#eb8282); }
.bar-row.tone-nh-n-thi-u .bar-fill { background: linear-gradient(90deg,#d35400,#f39c12); }
.bar-row.tone--a-xu-t-kho .bar-fill { background: linear-gradient(90deg,#1abc9c,#48e0c2); }
.bar-row.tone-nh-n-- .bar-fill { background: linear-gradient(90deg,#2ecc71,#61e39a); }
.bar-row.tone-k-ho-ch .bar-fill { background: linear-gradient(90deg,#95a5a6,#bdc3c7); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid > button[type="submit"] {
  justify-self: start;
  min-width: 220px;
}
.span2 { grid-column: span 2; }

.table-wrap { overflow: auto; max-height: 320px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: #fff;
}
th,
td {
  border: 1px solid #e1e9f4;
  padding: 7px 8px;
  text-align: left;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  background: #edf4fd;
  z-index: 1;
}
tbody tr:nth-child(even) { background: #f8fbff; }

.receive-item {
  border: 1px solid #dce4f2;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.scan-wrap {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.scan-audio {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid #dbe3f0;
  border-radius: 8px;
  background: #f8fbff;
}

.scan-audio-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.scan-audio input[type="range"] { width: 100%; }

.scan-list {
  border: 1px solid #dbe3f0;
  border-radius: 8px;
  padding: 8px;
  min-height: 42px;
  max-height: 180px;
  overflow: auto;
  display: grid;
  gap: 6px;
  background: #fff;
}

.qr-reader {
  margin-top: 10px;
  border: 1px solid #dbe3f0;
  border-radius: 8px;
  overflow: hidden;
  min-height: 220px;
  background: #fff;
}

.qr-reader video,
.qr-reader canvas {
  width: 100% !important;
  height: auto !important;
}

.scan-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #e2e8f4;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  background: #fff;
}

.scan-item button {
  padding: 5px 8px;
  font-size: 12px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.scan-highlight {
  box-shadow: 0 0 0 3px #8fc3f4;
  border-radius: 12px;
  transition: box-shadow .3s ease;
}

.admin-only.hidden-by-role { display: none; }

@media (max-width: 1080px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .top-actions {
    width: 100%;
  }
  .top-actions button {
    flex: 1;
  }
  .grid { grid-template-columns: 1fr; }
  .wide { grid-column: span 1; }
  .controls,
  .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: span 1; }
  .scan-wrap,
  .scan-audio-controls { grid-template-columns: 1fr; }
  .receive-item { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }

  button,
  select,
  input { min-height: 44px; }

  .login-wrap { padding: 14px; }
  .login-card { padding: 16px; }

  .topbar,
  .tabs,
  .controls,
  .dashboard-filter,
  .dashboard-insight,
  .kpis,
  .grid { margin-left: 8px; margin-right: 8px; }

  .tabs { padding: 8px; }
  .controls { padding: 10px; }
  .status { padding-left: 12px; padding-right: 12px; }

  .top-title h1 { font-size: 18px; }
  .brand-logo {
    width: 52px;
    height: 52px;
  }
  .tab { padding: 10px 12px; font-size: 13px; }

  .panel {
    padding: 10px;
    border-radius: 8px;
  }

  .form-grid > button[type="submit"] {
    width: 100%;
    min-width: 0;
  }

  .table-wrap { max-height: 260px; }
  th, td { font-size: 11px; }
}
