:root {
  color-scheme: light;
  --page: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #f8f9fb;
  --sidebar: #fbfbfc;
  --border: #e8eaee;
  --border-strong: #d9dde4;
  --text: #20232a;
  --muted: #737985;
  --faint: #9aa0aa;
  --accent: #315ee8;
  --accent-hover: #244bd0;
  --accent-soft: #edf2ff;
  --green: #23845b;
  --green-soft: #eaf6ef;
  --orange: #a76414;
  --orange-soft: #fff5e8;
  --shadow: 0 1px 2px rgb(22 29 42 / 4%), 0 8px 26px rgb(22 29 42 / 3%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-size: 14px;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 3;
  display: flex;
  width: 238px;
  flex-direction: column;
  padding: 22px 14px 16px;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -.3px;
}

.brand-mark {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border-radius: 9px;
  background: #222b3c;
  color: white;
  font-size: 15px;
  font-weight: 650;
}
.brand-amp { color: var(--muted); font-weight: 450; }
.nav-caption { margin: 39px 9px 10px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .095em; }
.main-nav { display: grid; gap: 4px; }

.nav-link {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 11px;
  padding: 0 10px;
  border-radius: 7px;
  color: #555b66;
  font-size: 13px;
  font-weight: 520;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: #f0f1f4; color: var(--text); }
.nav-link.is-active { background: #eceff5; color: #232a36; font-weight: 630; }
.nav-icon { width: 17px; color: #818894; font-size: 16px; text-align: center; }
.is-active .nav-icon { color: #454d5b; }
.sidebar-spacer { flex: 1; }

.retention-card {
  display: flex;
  gap: 10px;
  padding: 12px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: white;
}
.retention-icon { display: grid; width: 23px; height: 23px; place-items: center; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: 16px; }
.retention-card strong { display: block; margin: 1px 0 4px; font-size: 11px; font-weight: 650; }
.retention-card p { margin: 0; color: var(--muted); font-size: 10px; }
.server-status { display: flex; align-items: center; gap: 8px; padding: 17px 9px 1px; color: var(--muted); font-size: 11px; }
.status-dot { display: inline-block; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #43a878; box-shadow: 0 0 0 3px #43a8781a; }

.main-area { width: calc(100% - 238px); min-width: 0; margin-left: 238px; }
.topbar { display: flex; height: 57px; align-items: center; justify-content: space-between; padding: 0 36px; border-bottom: 1px solid var(--border); background: rgb(255 255 255 / 72%); }
.breadcrumb { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.breadcrumb strong { color: #30343c; font-weight: 590; }
.breadcrumb-separator { color: #c3c6cd; }
.local-badge { display: flex; align-items: center; gap: 8px; color: #59606c; font-size: 11px; }
.local-badge .status-dot { width: 6px; height: 6px; }
.page-content { width: min(1320px, 100%); margin: 0 auto; padding: 30px 36px 48px; }

.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 23px; }
.eyebrow { margin: 0 0 7px; color: #858b96; font-size: 10px; font-weight: 680; letter-spacing: .105em; }
h1 { margin: 0; font-size: 25px; font-weight: 650; letter-spacing: -.8px; }
.page-description { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.heading-period { display: flex; align-items: center; gap: 9px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 7px; background: white; color: #59606c; font-size: 11px; }
.heading-period .status-dot { width: 6px; height: 6px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-bottom: 17px; }
.stat-grid:has(.stat-card:nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-card { display: flex; min-height: 83px; align-items: center; gap: 13px; padding: 15px 17px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow); }
.stat-icon { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border-radius: 9px; font-size: 10px; font-weight: 750; letter-spacing: -.3px; }
.pdf-icon { background: #fff0ee; color: #bd5147; }
.folder-icon { background: #fff5df; color: #a87619; font-size: 16px; }
.excel-icon { background: #e9f6ef; color: #278054; }
.stat-card p { margin: 0 0 5px; color: var(--muted); font-size: 11px; }
.stat-card strong { font-size: 20px; font-weight: 650; letter-spacing: -.45px; }

.panel { min-width: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.upload-panel { margin-bottom: 17px; padding: 17px 18px 13px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 14px; }
.panel-heading h2 { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: -.1px; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.subtle-tag { padding: 5px 8px; border-radius: 5px; background: #f2f3f5; color: #69707b; font-size: 10px; font-weight: 550; }

.dropzone { display: flex; min-height: 88px; align-items: center; gap: 14px; padding: 14px 15px; border: 1px dashed #cbd1dc; border-radius: 8px; background: #fcfcfd; transition: background .15s, border-color .15s; }
.dropzone.is-dragging, .dropzone:focus-visible { border-color: var(--accent); outline: none; background: #f5f7ff; }
.upload-icon { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border: 1px solid #e4e7ed; border-radius: 9px; background: white; color: #646c79; font-size: 21px; }
.dropzone-copy { display: grid; flex: 1; gap: 5px; }
.dropzone-copy strong { font-size: 12px; font-weight: 620; }
.dropzone-copy span { color: var(--muted); font-size: 10px; line-height: 1.5; }
.upload-actions { display: flex; gap: 7px; }
.button { display: inline-flex; min-height: 32px; align-items: center; justify-content: center; gap: 7px; padding: 0 11px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-size: 11px; font-weight: 590; transition: background .15s, border-color .15s, transform .15s; }
.button:disabled { cursor: not-allowed; opacity: .56; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button-secondary { border-color: var(--border-strong); background: white; color: #424853; }
.button-secondary:hover:not(:disabled) { border-color: #b7beca; background: #fafbfc; }
.button-primary { background: var(--accent); color: white; }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button-danger { border-color: #f0d7d4; background: white; color: #ad4941; }
.button-danger:hover:not(:disabled) { border-color: #e5bcb8; background: #fff7f6; }
.button-small { min-height: 29px; padding: 0 9px; font-size: 10px; }
.button-link { min-height: 28px; padding: 0 5px; background: transparent; color: var(--accent); }
.upload-status { min-height: 14px; margin: 8px 2px 0; color: var(--muted); font-size: 10px; }
.upload-status.is-error { color: #b53c37; }

.workspace-grid { display: grid; grid-template-columns: minmax(245px, .75fr) minmax(0, 1.7fr); gap: 17px; align-items: start; }
.periods-panel, .detail-panel { min-height: 320px; }
.periods-panel { padding: 17px 14px 12px; top: 0px; position: sticky;}
.periods-panel > .panel-heading { padding: 0 4px; }
.period-list { display: grid; gap: 4px; }
.period-item { display: flex; min-height: 51px; align-items: center; gap: 10px; padding: 7px 8px; border: 1px solid transparent; border-radius: 7px; cursor: pointer; transition: background .13s, border-color .13s; }
.period-item:hover { background: #f8f9fb; }
.period-item.is-selected { border-color: #e0e6f4; background: #f4f6fb; }
.period-item.is-drop-target { border-color: var(--accent); background: var(--accent-soft); }
.period-folder-icon { display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center; border-radius: 7px; background: #f4f1e9; color: #94722a; font-size: 14px; }
.period-item.is-unsorted .period-folder-icon { background: var(--orange-soft); color: var(--orange); }
.period-label { min-width: 0; flex: 1; overflow: hidden; color: #343943; font-size: 11px; font-weight: 580; text-overflow: ellipsis; white-space: nowrap; }
.period-meta { display: grid; justify-items: end; gap: 2px; color: var(--muted); font-size: 10px; }
.period-count { min-width: 20px; text-align: right; font-weight: 600; }
.period-empty { padding: 9px 8px; border: 1px dashed #e2e5eb; border-radius: 7px; color: var(--muted); font-size: 10px; text-align: center; }

.detail-panel { padding: 17px 18px; }
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid #eef0f3; }
.detail-title { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.25px; }
.detail-count { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; color: var(--muted); font-size: 10px; }
.detail-actions { display: flex; align-items: center; gap: 7px; }
.file-search { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0 2px; }
.file-search-input { display: flex; width: min(320px, 100%); min-height: 32px; align-items: center; gap: 8px; padding: 0 9px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--muted); }
.file-search-input:focus-within { border-color: #9caff4; box-shadow: 0 0 0 2px #315ee815; }
.file-search-input > span { font-size: 17px; line-height: 1; }
.file-search-input input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 11px; }
.file-search-input input::placeholder { color: var(--faint); }
.file-search-count { flex: 0 0 auto; color: var(--muted); font-size: 10px; }
.file-list { display: grid; }
.file-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 55px; border-bottom: 1px solid #f0f1f3; }
.file-row[hidden] { display: none; }
.search-empty { margin-top: 10px; }
.file-row:last-child { border-bottom: 0; }
.file-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.file-icon { display: grid; width: 28px; height: 32px; place-items: center; border: 1px solid #f0d7d4; border-radius: 5px; background: #fff8f7; color: #b55147; font-size: 8px; font-weight: 750; }
.file-name { overflow: hidden; color: #383d46; font-size: 11px; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.file-expiry { margin-top: 4px; color: var(--faint); font-size: 9px; }
.file-row .file-actions .button { opacity: .86; }
.file-row:hover .file-actions .button { opacity: 1; }
.empty-state { display: grid; justify-items: center; gap: 8px; padding: 27px 14px; color: var(--muted); font-size: 11px; text-align: center; }
.empty-state strong { color: #474d58; font-size: 12px; font-weight: 600; }
.empty-icon { display: grid; width: 39px; height: 39px; margin-bottom: 3px; place-items: center; border: 1px solid var(--border); border-radius: 10px; background: #fafbfc; color: #828996; font-size: 18px; }
.detail-empty { min-height: 280px; align-content: center; }
.detail-empty span:last-child { max-width: 220px; line-height: 1.5; }
.unsorted-note { margin: 12px 0; padding: 9px 10px; border: 1px solid #f3e3cb; border-radius: 7px; background: #fffaf3; color: #8c5a1a; font-size: 10px; line-height: 1.5; }
.classify-form { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 12px 0 5px; }
.classify-form select { min-height: 30px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: 6px; background: white; color: #414752; font-size: 10px; }
.classify-form label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.classify-form input[type=checkbox] { accent-color: var(--accent); }
.file-select { display: grid; width: 18px; place-items: center; }
.file-select input { margin: 0; accent-color: var(--accent); }
.file-row:has(.file-select) { grid-template-columns: 18px 30px minmax(0, 1fr) auto; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }

.archive-panel { padding: 17px 18px; }
.archive-panel > .panel-heading { margin-bottom: 12px; }
.table-wrap { width: 100%; overflow-x: auto; }
.file-table { width: 100%; border-collapse: collapse; text-align: left; }
.file-table th { height: 35px; border-bottom: 1px solid var(--border); color: #8a909a; font-size: 9px; font-weight: 650; letter-spacing: .065em; white-space: nowrap; }
.file-table td { height: 55px; border-bottom: 1px solid #f0f1f3; color: #555b65; font-size: 11px; white-space: nowrap; }
.file-table tbody tr:last-child td { border-bottom: 0; }
.file-table th:first-child, .file-table td:first-child { padding-left: 5px; }
.table-file { display: flex; align-items: center; gap: 9px; color: #383d46; font-weight: 570; }
.table-file .file-icon { width: 25px; height: 29px; }
.period-pill { display: inline-flex; padding: 5px 8px; border-radius: 5px; background: #f2f4f7; color: #515966; font-size: 10px; }
.table-expiry { color: var(--muted); }
.table-empty { height: 120px !important; color: var(--muted) !important; text-align: center; }

.toast { position: fixed; right: 23px; bottom: 22px; z-index: 10; max-width: min(420px, calc(100vw - 32px)); max-height: min(60vh, 360px); overflow: auto; overflow-wrap: anywhere; white-space: pre-line; padding: 11px 15px; transform: translateY(12px); border: 1px solid #dfe3e9; border-radius: 8px; background: white; box-shadow: 0 8px 30px rgb(25 34 48 / 12%); color: #343943; font-size: 11px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; }
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast.is-error { border-color: #f0d0ce; color: #a23e38; }

.confirmation-modal { width: min(440px, calc(100vw - 32px)); padding: 22px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(25 34 48 / 22%); }
.confirmation-modal::backdrop { background: rgb(25 34 48 / 42%); backdrop-filter: blur(2px); }
.confirmation-content { display: flex; align-items: flex-start; gap: 13px; }
.confirmation-icon { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #fff0ee; color: #ad4941; font-size: 17px; font-weight: 700; }
.confirmation-content h2 { margin: 2px 0 7px; font-size: 15px; font-weight: 650; }
.confirmation-content p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.confirmation-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.confirmation-modal :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 1000px) {
  .sidebar { width: 205px; }
  .main-area { width: calc(100% - 205px); margin-left: 205px; }
  .topbar { padding-right: 23px; padding-left: 23px; }
  .page-content { padding-right: 23px; padding-left: 23px; }
  .workspace-grid { grid-template-columns: minmax(220px, .8fr) minmax(0, 1.4fr); gap: 12px; }
  .dropzone { flex-wrap: wrap; }
  .upload-actions { width: 100%; padding-left: 50px; }
}

@media (max-width: 720px) {
  .sidebar { position: sticky; inset: 0 auto auto 0; width: 61px; height: 100vh; padding: 14px 7px; }
  .brand { justify-content: center; padding: 0; }
  .brand > span:last-child, .nav-caption, .nav-link > span:last-child, .retention-card, .server-status { display: none; }
  .main-nav { margin-top: 30px; }
  .nav-link { justify-content: center; padding: 0; }
  .nav-icon { width: auto; font-size: 17px; }
  .main-area { width: calc(100% - 61px); margin-left: 0; }
  .topbar { height: 49px; padding: 0 15px; }
  .breadcrumb { gap: 6px; font-size: 10px; }
  .local-badge { gap: 5px; font-size: 9px; }
  .page-content { padding: 23px 15px 35px; }
  .page-heading { align-items: flex-start; }
  h1 { font-size: 22px; }
  .heading-period { padding: 7px 8px; font-size: 9px; }
  .stat-grid { gap: 8px; }
  .stat-card { min-height: 71px; gap: 8px; padding: 10px; }
  .stat-icon { width: 30px; height: 30px; }
  .stat-card p { font-size: 9px; }
  .stat-card strong { font-size: 17px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .periods-panel { min-height: auto; }
  .detail-panel { min-height: 255px; }
  .detail-empty { min-height: 215px; }
  .upload-actions { padding-left: 0; }
}

@media (max-width: 480px) {
  .local-badge { max-width: 115px; }
  .page-heading { flex-direction: column; }
  .page-heading > .button { align-self: flex-start; }
  .stat-grid { grid-template-columns: 1fr; }
  .stat-grid:has(.stat-card:nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card { min-height: 62px; }
  .dropzone { align-items: flex-start; }
  .dropzone-copy { flex-basis: calc(100% - 55px); }
  .upload-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .upload-actions .button { padding: 0 7px; font-size: 10px; }
  .detail-header { flex-direction: column; }
  .detail-actions { width: 100%; }
}
