:root {
  --blue: #315cff;
  --blue-dark: #172a52;
  --blue-soft: #e8edff;
  --ink: #17233f;
  --muted: #71809c;
  --line: #e3e8f2;
  --canvas: #f4f6fb;
  --surface: #fff;
  --danger: #c43e55;
  --success: #19886b;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid rgba(49, 92, 255, .36); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; background: radial-gradient(circle at 12% 8%, rgba(49, 92, 255, .08), transparent 35%), var(--canvas); }
.login-card { width: min(100%, 430px); padding: 42px 44px 46px; background: var(--surface); border: 1px solid rgba(227, 232, 242, .84); border-radius: 20px; box-shadow: 0 18px 52px rgba(23, 42, 82, .10); }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 25px; color: #fff; font-size: 21px; font-weight: 800; border-radius: 13px; background: var(--blue); box-shadow: 0 10px 22px rgba(49, 92, 255, .26); }
.brand-mark-small { width: 35px; height: 35px; margin: 0; font-size: 16px; border-radius: 10px; box-shadow: none; }
.eyebrow, .section-label, .topbar-kicker { margin: 0 0 7px; color: var(--blue); font-size: 12px; font-weight: 750; letter-spacing: .08em; }
.login-card h1 { margin: 0; color: var(--blue-dark); font-size: 28px; letter-spacing: -.04em; }
.login-lede { margin: 10px 0 31px; color: var(--muted); font-size: 14px; }
.login-card form { display: grid; gap: 9px; }
.login-card label { margin-top: 8px; color: #52617e; font-size: 13px; font-weight: 650; }
input, select { min-height: 44px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; padding: 0 13px; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
input::placeholder { color: #a2aec2; }
input:focus, select:focus { outline: none; border-color: var(--blue); background: #fff; box-shadow: 0 0 0 4px rgba(49, 92, 255, .10); }
.button { min-height: 40px; border: 1px solid transparent; border-radius: 9px; padding: 0 16px; font-size: 13px; font-weight: 700; transition: transform .16s ease, background .16s ease, border-color .16s ease, color .16s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--blue); box-shadow: 0 6px 14px rgba(49, 92, 255, .18); }
.button-primary:hover:not(:disabled) { background: #274ee4; }
.button-wide { width: 100%; min-height: 46px; margin-top: 18px; }
.button-outline { color: var(--blue); border-color: #bfcaff; background: #f8f9ff; }
.button-outline:hover:not(:disabled) { background: var(--blue-soft); border-color: var(--blue); }
.button-quiet { color: #596985; border-color: var(--line); background: #fff; }
.button-quiet:hover:not(:disabled) { color: var(--blue); border-color: #bfcaff; }
.button-danger { color: var(--danger); border-color: #f1cbd2; background: #fff8f9; }
.button-danger:hover:not(:disabled) { background: #fff0f3; }
.form-message { margin: 9px 0 0; padding: 10px 12px; color: var(--danger); border-radius: 8px; background: #fff1f3; font-size: 13px; line-height: 1.5; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; width: 238px; display: flex; flex-direction: column; padding: 26px 16px 19px; color: rgba(255,255,255,.72); background: var(--blue-dark); }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 11px 43px; color: #fff; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: 15px; letter-spacing: .01em; }
.sidebar-brand div span:last-child { margin-top: 3px; color: rgba(255,255,255,.52); font-size: 11px; }
.nav-list { display: grid; gap: 7px; }
.nav-item { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 13px; padding: 0 13px; color: rgba(255,255,255,.68); border: 0; border-radius: 10px; background: transparent; font-size: 13px; font-weight: 650; text-align: left; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-item.is-active { color: #fff; background: var(--blue); box-shadow: 0 7px 16px rgba(0,0,0,.12); }
.nav-icon { width: 18px; color: currentColor; font-size: 19px; font-weight: 400; line-height: 1; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 16px 9px 0; border-top: 1px solid rgba(255,255,255,.12); }
.account-chip { display: flex; align-items: center; gap: 10px; min-width: 0; color: #fff; font-size: 12px; font-weight: 650; }
.account-chip > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-avatar { width: 29px; height: 29px; display: grid; flex: 0 0 auto; place-items: center; color: var(--blue-dark); border-radius: 50%; background: #dfe6ff; font-size: 11px; }
.logout-button { display: flex; align-items: center; gap: 8px; margin-top: 17px; padding: 0; color: rgba(255,255,255,.55); border: 0; background: transparent; font-size: 12px; }
.logout-button:hover { color: #fff; }
.main-column { width: calc(100% - 238px); min-width: 0; margin-left: 238px; }
.topbar { min-height: 94px; display: flex; align-items: center; justify-content: space-between; padding: 22px clamp(24px, 4vw, 60px); background: #fff; border-bottom: 1px solid var(--line); }
.topbar-kicker { margin-bottom: 3px; color: #8490a8; font-size: 11px; letter-spacing: .04em; }
.topbar h2 { margin: 0; color: var(--blue-dark); font-size: 23px; letter-spacing: -.03em; }
.topbar-meta { display: flex; align-items: center; gap: 8px; color: #7b88a0; font-size: 12px; }
.status-dot { width: 7px; height: 7px; display: block; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(25, 136, 107, .10); }
.content { width: min(100%, 1260px); margin: 0 auto; padding: 44px clamp(24px, 4vw, 60px) 70px; }
.page-section { animation: page-in .24s ease both; }
@keyframes page-in { from { opacity: .35; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.section-heading h3 { margin: 0; color: var(--blue-dark); font-size: 25px; letter-spacing: -.04em; }
.section-note { margin: 0 0 2px; color: var(--muted); font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 13px; }
.stat-card { min-height: 153px; display: flex; flex-direction: column; padding: 21px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat-card-blue { color: #fff; border-color: var(--blue); background: var(--blue); box-shadow: 0 12px 23px rgba(49, 92, 255, .18); }
.stat-card-today { border-color: #d4defd; background: #eef2ff; }
.stat-label { color: #74829c; font-size: 12px; font-weight: 650; }
.stat-card-blue .stat-label { color: rgba(255,255,255,.72); }
.stat-card strong { margin-top: 16px; color: var(--blue-dark); font-size: 33px; font-weight: 740; letter-spacing: -.05em; line-height: 1; }
.stat-card-blue strong { color: #fff; }
.stat-foot { margin-top: auto; color: #a0abc0; font-size: 11px; }
.stat-card-blue .stat-foot { color: rgba(255,255,255,.62); }
.loading-state { padding: 35px 0; color: var(--muted); font-size: 13px; }
.empty-state { margin-top: 17px; padding: 68px 20px; color: var(--muted); border: 1px dashed #cfd7e6; border-radius: var(--radius); background: rgba(255,255,255,.55); text-align: center; }
.empty-state.compact { margin: 0; padding: 48px 20px; border: 0; border-radius: 0; background: #fff; }
.empty-mark { width: 35px; height: 35px; display: grid; place-items: center; margin: 0 auto 13px; color: var(--blue); border: 1px solid #cbd5ff; border-radius: 50%; font-size: 21px; }
.empty-state h4 { margin: 0; color: var(--blue-dark); font-size: 15px; }
.empty-state p { margin: 8px 0 0; font-size: 12px; }
.error-state, .inline-feedback { padding: 12px 14px; color: var(--danger); border: 1px solid #f2cdd4; border-radius: 9px; background: #fff3f5; font-size: 13px; line-height: 1.5; }
.inline-feedback.is-success { color: var(--success); border-color: #c9ebdf; background: #effaf6; }
.error-state { margin-top: 17px; }
.inline-feedback { margin: -8px 0 16px; }
.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.search-field { position: relative; flex: 1 1 260px; min-width: 180px; }
.search-field input { width: 100%; padding-left: 37px; }
.search-icon { position: absolute; z-index: 1; top: 11px; left: 14px; color: #9da9bf; font-size: 20px; line-height: 20px; }
.select-field { min-width: 145px; }
.select-field select { width: 100%; }
.date-field { min-width: 148px; }
.date-field input { width: 100%; }
.table-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 7px 20px rgba(23,42,82,.03); }
.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; text-align: left; }
th { padding: 14px 18px; color: #8a96ac; border-bottom: 1px solid var(--line); background: #fbfcfe; font-size: 11px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
td { padding: 17px 18px; color: #53627e; border-bottom: 1px solid #edf0f6; font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcff; }
.cell-title { display: block; max-width: 260px; overflow: hidden; color: var(--ink); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.cell-subtitle { display: block; max-width: 260px; margin-top: 4px; overflow: hidden; color: #9ba7ba; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-active { color: #16775f; background: #e2f6ee; }
.status-terminated { color: #a76718; background: #fff1d9; }
.status-deleted { color: #7e879a; background: #edf0f5; }
.status-hidden { color: #a76718; background: #fff1d9; }
.dialog { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px; background: rgba(23, 42, 82, .42); }
.dialog-card { width: min(100%, 560px); max-height: calc(100vh - 48px); overflow: auto; padding: 28px 28px 24px; border-radius: 18px; background: #fff; box-shadow: 0 24px 60px rgba(23, 42, 82, .22); }
.dialog-card h3 { margin: 0 0 18px; color: var(--blue-dark); font-size: 20px; }
.dialog-card form { display: grid; gap: 8px; }
.dialog-card label { margin-top: 8px; color: #52617e; font-size: 13px; font-weight: 650; }
.dialog-card textarea { width: 100%; min-height: 88px; padding: 10px 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; resize: vertical; }
.dialog-card textarea:focus { outline: none; border-color: var(--blue); background: #fff; box-shadow: 0 0 0 4px rgba(49, 92, 255, .10); }
.dialog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.dialog-grid label { margin-top: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.category-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.category-list { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.category-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: #53627e; font-size: 12px; font-weight: 650; }
.category-chip button { padding: 0; color: #8a96ac; border: 0; background: transparent; font-size: 12px; }
.category-chip button:hover { color: var(--blue); }
.status-unknown { color: #596985; background: #edf2ff; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; white-space: nowrap; }
.row-action { padding: 5px 7px; color: #60708d; border: 0; border-radius: 6px; background: transparent; font-size: 12px; font-weight: 650; }
.row-action:hover { color: var(--blue); background: var(--blue-soft); }
.row-action.danger:hover { color: var(--danger); background: #fff0f3; }
.thumb-list { display: flex; align-items: center; gap: 5px; }
.record-thumb, .image-fallback { width: 33px; height: 33px; display: block; flex: 0 0 auto; border-radius: 6px; }
.record-thumb { object-fit: cover; border: 1px solid var(--line); background: #f7f8fb; }
.image-fallback { display: grid; place-items: center; color: #a5afc0; border: 1px dashed #cdd5e3; font-size: 15px; }
.image-count { color: #8490a8; font-size: 11px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding-top: 18px; color: #7b88a0; font-size: 12px; }
.pagination .button { min-height: 34px; padding: 0 11px; }
.mobile-nav-toggle, .mobile-nav { display: none; }

@media (max-width: 1080px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-card-today { grid-column: span 1; }
}

@media (max-width: 720px) {
  .login-card { padding: 34px 25px 36px; }
  .sidebar { display: none; }
  .main-column { width: 100%; margin-left: 0; }
  .topbar { min-height: 75px; padding: 17px 18px; }
  .mobile-nav-toggle { width: 37px; height: 37px; display: grid; place-items: center; margin-right: 12px; color: var(--blue-dark); border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 17px; }
  .topbar > div:nth-child(2) { flex: 1; }
  .topbar h2 { font-size: 20px; }
  .topbar-meta { display: none; }
  .mobile-nav { position: absolute; z-index: 9; top: 76px; right: 18px; left: 18px; display: grid; grid-template-columns: repeat(3, 1fr); padding: 6px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: 0 12px 30px rgba(23,42,82,.13); }
  .dialog { padding: 12px; }
  .dialog-card { padding: 22px 18px 18px; }
  .dialog-grid { grid-template-columns: 1fr; }
  .mobile-nav button { min-height: 38px; color: #677690; border: 0; border-radius: 7px; background: transparent; font-size: 12px; }
  .mobile-nav button:hover, .mobile-nav button:focus-visible { color: var(--blue); background: var(--blue-soft); }
  .content { padding: 28px 17px 48px; }
  .section-heading { display: block; margin-bottom: 20px; }
  .section-note { margin-top: 7px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat-card { min-height: 132px; padding: 16px; }
  .stat-card strong { margin-top: 13px; font-size: 28px; }
  .filter-bar { align-items: stretch; flex-wrap: wrap; }
  .search-field { flex-basis: 100%; }
  .select-field, .date-field { flex: 1; min-width: 0; }
  .filter-bar > .button { flex: 0 0 auto; }
  .records-filter #records-export { flex: 1; }
  .table-card { border-radius: 11px; }
  th, td { padding-right: 14px; padding-left: 14px; }
  .pagination { justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
