/* ===== Trang nội bộ — dùng chung biến & thành phần từ style.css ===== */

body.internal { background: var(--bg); }
[hidden] { display: none !important; }

/* Màu trạng thái */
[data-status="MOI"] { --st: #2563eb; --st-bg: #e8f0fe; }
[data-status="DA_NHAN"] { --st: #c27c0e; --st-bg: #fdf3dc; }
[data-status="UNKNOWN"] { --st: #6b7280; --st-bg: #eef0f2; }
[data-status="XE_VAO"] { --st: #c27c0e; --st-bg: #fdf3dc; }
[data-status="DANG_SANG_TAI"] { --st: #db6a13; --st-bg: #fdeedd; }
[data-status="HOAN_THANH"] { --st: #0f8a6a; --st-bg: #def5ee; }
[data-status="DA_RA"] { --st: #15803d; --st-bg: #e3f4e8; }
[data-status="TU_CHOI"], [data-status="HUY"] { --st: #6b7280; --st-bg: #eef0f2; }

.badge-st {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  border-radius: 999px;
  background: var(--st-bg); color: var(--st);
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge-st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ===== Đăng nhập ===== */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login__art {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  padding: 48px;
  color: #fff;
  background:
    radial-gradient(700px 360px at 90% 0%, rgba(212, 161, 42, .35), transparent 60%),
    linear-gradient(150deg, var(--primary-900), var(--primary) 85%);
}
.login__art::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,.035) 0 2px, transparent 2px 22px);
}
.login__art-inner { position: relative; z-index: 1; max-width: 380px; }
.login__art img { border-radius: 18px; box-shadow: 0 14px 30px -10px rgba(0,0,0,.5); }
.login__art h2 { margin-top: 20px; font-size: 28px; font-weight: 800; }
.login__art p { margin-top: 6px; color: rgba(255,255,255,.78); }
.login__flow { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 10px; }
.login__flow li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  font-weight: 500; font-size: 14px;
}
.login__flow b {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--accent); color: #3d2a00; font-size: 13px;
}
.login__panel { display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.login__card { width: 100%; max-width: 380px; display: grid; gap: 16px; }
.login__logo { display: none; border-radius: 14px; }
.login__card h1 { font-size: 26px; font-weight: 800; color: var(--primary-900); }
.login__sub { margin-top: -12px; color: var(--muted); }
.login__back { text-align: center; color: var(--muted); font-size: 13.5px; text-decoration: none; }
.login__back:hover { color: var(--primary-700); }

.pw { position: relative; }
.pw input { padding-right: 64px; }
.pw__toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  height: 34px; padding: 0 10px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--primary-700);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.pw__toggle:hover { background: var(--primary-50); }

.alert {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--danger-50); color: var(--danger);
  border: 1px solid #f4c5c5;
  font-size: 13.5px; font-weight: 500;
}
.btn--block { width: 100%; }
.btn--sm { height: 38px; padding: 0 14px; font-size: 13.5px; border-radius: 10px; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--outline { background: #fff; border: 1.5px solid var(--line-strong); color: var(--ink); }
.btn--outline:hover { border-color: var(--primary); color: var(--primary-700); }
.btn .spinner { margin-left: 2px; }
.btn--ghost .spinner, .btn--outline .spinner { border-color: rgba(15,99,48,.25); border-top-color: var(--primary-700); }

select {
  height: 46px; padding: 0 36px 0 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fbfcfb url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6d64' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 12px center / 16px no-repeat;
  appearance: none;
  outline: none;
  cursor: pointer;
}
select:focus { border-color: var(--primary); box-shadow: var(--ring); }

/* ===== Topbar & tabs ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 24px;
  background: linear-gradient(120deg, var(--primary-900), var(--primary));
  color: #fff;
}
.topbar__brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; }
.topbar__brand img { border-radius: 9px; }
.topbar__user { display: flex; align-items: center; gap: 10px; }
.topbar .btn--ghost { background: rgba(255,255,255,.12); color: #fff; }
.topbar .btn--ghost:hover { background: rgba(255,255,255,.22); }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; margin-right: 6px; }
.who b { font-size: 14px; }
.role-chip { font-size: 11.5px; font-weight: 600; color: #ffe39a; }

.tabs {
  display: flex; gap: 4px; overflow-x: auto;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  height: 50px; padding: 0 14px;
  border: 0; background: none;
  color: var(--muted); font-weight: 600; font-size: 14px;
  white-space: nowrap; cursor: pointer; text-decoration: none;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--primary-700); }
.tab.is-active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--primary); }
.tab__badge { min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; border-radius: 999px; background: var(--danger); color: #fff; font-size: 12px; }
.tab__badge[data-zero] { background: #dfe6e1; color: var(--muted); }
.tab--link { margin-left: auto; color: var(--primary-700); }

.dash { max-width: 1200px; margin: 0 auto; padding: 20px 24px 60px; }
.role-hint {
  margin-bottom: 14px; padding: 12px 16px;
  border-radius: 12px;
  background: var(--accent-50); border: 1px solid #f1dfae;
  color: #6b4b06; font-size: 13.5px;
}

/* ===== Pipeline quy trình ===== */
.pipeline { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(140px, .7fr); gap: 8px; margin-bottom: 16px; }
.stage {
  position: relative;
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  text-align: left; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.stage:hover { border-color: var(--st); }
.stage.is-active { border-color: var(--st); box-shadow: 0 0 0 3px var(--st-bg); }
.stage.is-mine::after {
  content: "Việc của bạn"; position: absolute; top: -9px; right: 10px;
  padding: 1px 7px; border-radius: 6px;
  background: var(--accent); color: #3d2a00; font-size: 10.5px; font-weight: 700;
}
.stage__n { font-size: 24px; font-weight: 800; color: var(--st); line-height: 1.1; }
.stage__label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.stage__role { font-size: 11.5px; color: var(--muted); }
.stage--closed { min-width: 120px; }

/* ===== Toolbar ===== */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; height: 42px; padding-left: 42px; border: 1.5px solid var(--line-strong); border-radius: 12px; background: #fff; outline: none; }
.search input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.toolbar select { height: 42px; background-color: #fff; }
.toolbar .btn--ghost { background: #fff; border: 1.5px solid var(--line-strong); height: 42px; }
#lastSync { font-weight: 500; color: var(--muted); }

/* ===== Danh sách ===== */
.reglist { display: grid; gap: 10px; }
.reg {
  display: grid;
  grid-template-columns: 150px minmax(0, 1.4fr) minmax(0, 1.2fr) 170px auto;
  grid-template-areas: "head main plates status actions";
  gap: 6px 16px; align-items: center;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--st);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
}
.reg:hover { box-shadow: var(--shadow); }
.reg__head { grid-area: head; min-width: 0; }
.reg__main { grid-area: main; min-width: 0; }
.reg__plates { grid-area: plates; min-width: 0; }
.reg__status { grid-area: status; }
.reg:focus-visible { outline: none; box-shadow: var(--ring); }
.reg__id { font-weight: 800; font-size: 14px; letter-spacing: .02em; }
.reg__date { font-size: 12.5px; color: var(--muted); }
.reg__company { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reg__meta { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plates { display: flex; flex-wrap: wrap; gap: 4px; }
.plate-tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 8px;
  border-radius: 6px;
  background: #f1f4f2; border: 1px solid var(--line);
  font-size: 12px; font-weight: 700; letter-spacing: .03em; white-space: nowrap;
}
.plate-tag i { font-style: normal; font-size: 9.5px; font-weight: 800; color: var(--muted); }
.plate-tag--more { color: var(--muted); font-weight: 600; }
.reg__actions { grid-area: actions; display: flex; gap: 6px; justify-content: flex-end; }
.reg__actions .btn { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }

.empty {
  padding: 48px 16px; text-align: center; color: var(--muted);
  border: 1.5px dashed var(--line-strong); border-radius: 16px; background: #fff;
}
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.skeleton { height: 74px; border-radius: 14px; background: linear-gradient(90deg, #eef2ef 25%, #f6f8f7 50%, #eef2ef 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== Drawer ===== */
.drawer-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(10, 30, 18, .35); animation: fade .2s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 31;
  width: min(560px, 100%);
  display: flex; flex-direction: column;
  background: #fff;
  box-shadow: -20px 0 50px -20px rgba(0,0,0,.35);
  animation: slideIn .25s cubic-bezier(.2, .9, .3, 1);
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
.drawer__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 24px 14px; border-bottom: 1px solid var(--line); }
.drawer__eyebrow { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.drawer__head h2 { font-size: 22px; font-weight: 800; letter-spacing: .03em; }
.drawer__body { flex: 1; overflow-y: auto; padding: 18px 24px 24px; }
.drawer__foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); background: #fafcfb; }
.drawer__foot:empty { display: none; }
.drawer__foot .btn { flex: 1; min-width: 140px; }
.icon-btn--plain:hover { background: #eef2ef; color: var(--ink); }

.dl { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 14px; margin: 14px 0 20px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; word-break: break-word; }
.dl a { color: var(--primary-700); }
.sec-title { margin: 22px 0 10px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--primary-900); }

.vtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.vtable th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.vtable td { padding: 9px 8px; border-bottom: 1px dashed var(--line); }
.vtable td.plate-cell { font-weight: 800; letter-spacing: .04em; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 6px; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary);
}
.timeline li:last-child::before { background: var(--primary); }
.tl__head { font-weight: 700; font-size: 14px; }
.tl__meta { font-size: 12.5px; color: var(--muted); }
.tl__note { margin-top: 4px; padding: 6px 10px; border-radius: 8px; background: #f4f7f5; font-size: 13px; }

/* ===== Users ===== */
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 14px; }
.panel-head h2 { font-size: 20px; font-weight: 800; color: var(--primary-900); }
.panel-head p { color: var(--muted); font-size: 13.5px; }
.roles-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.role-card { padding: 12px 14px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.role-card b { display: block; font-size: 14px; }
.role-card span { font-size: 12.5px; color: var(--muted); }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 12px 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f7faf8; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.table .row-actions .btn { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill--on { background: var(--primary-50); color: var(--primary-700); }
.pill--off { background: #eef0f2; color: #6b7280; }
.pill--warn { background: var(--accent-50); color: #7a5608; margin-left: 6px; }

/* ===== Modal form ===== */
.modal__box--form { text-align: left; display: grid; gap: 14px; }
.modal__box--form h3 { margin-bottom: 0; }
.modal__box--form select { width: 100%; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: relative; width: 40px; height: 22px; border-radius: 99px; background: #cfd9d2; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: var(--ring); }

/* ===== Responsive ===== */
@media (max-width: 1080px) {
  .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reg { grid-template-columns: 140px minmax(0, 1fr) auto; grid-template-areas: "head main status" "head plates actions"; }
}
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login__art { display: none; }
  .login__logo { display: block; }
  .roles-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .topbar__brand span { display: none; }
  .who { display: none; }
  .tabs { padding: 0 8px; }
  .tab--link { margin-left: 0; }
  .dash { padding: 16px 16px 48px; }
  .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { padding: 10px 12px; }
  .stage__n { font-size: 20px; }
  .reg { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "head status" "main main" "plates plates" "actions actions"; gap: 8px 12px; padding: 12px 14px; }
  .reg__actions { justify-content: stretch; }
  .reg__actions:empty { display: none; }
  .reg__actions .btn { flex: 1; }
  .drawer__head, .drawer__body, .drawer__foot { padding-left: 16px; padding-right: 16px; }
  .dl { grid-template-columns: 110px minmax(0, 1fr); }
  .panel-head { flex-direction: column; align-items: stretch; }
  .roles-legend { grid-template-columns: minmax(0, 1fr); }
}

/* ===== Tiền, báo cáo ===== */
.reg__status { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.reg__money, .money { font-weight: 800; color: var(--primary-700); font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-input { position: relative; }
.money-input input { padding-right: 36px; font-size: 18px; font-weight: 700; letter-spacing: .02em; }
.money-input span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; }
.btn--danger-outline { color: var(--danger); }
.btn--danger-outline:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-50); }

.report-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.report-tools input[type="date"] { height: 38px; width: auto; border-radius: 10px; }
.report-tools [data-shift] { width: 38px; padding: 0; font-size: 18px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 6px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.kpi__label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kpi__value { font-size: 24px; font-weight: 800; color: var(--primary-900); font-variant-numeric: tabular-nums; }
.kpi__sub { font-size: 12px; color: var(--muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .plate-cell { font-weight: 800; letter-spacing: .04em; }
.table__empty { text-align: center; color: var(--muted); padding: 28px 14px !important; }
.muted { color: var(--muted); font-size: 12.5px; }
#reportPanel .sec-title { margin-top: 20px; }

@media (max-width: 860px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .report-tools input[type="date"] { flex: 1; }
  .reg__status { flex-direction: row; align-items: center; justify-self: end; }
}
