:root {
  color-scheme: light;
  --page: #eff5fc;
  --surface: #ffffff;
  --ink: #172d4f;
  --muted: #63758e;
  --soft-muted: #8b9ab0;
  --line: #dce6f2;
  --line-strong: #c8d8ea;
  --green: #28588f;
  --green-dark: #183d68;
  --green-soft: #eaf2fb;
  --amber: #9a6718;
  --amber-soft: #fbf3e4;
  --red: #a34743;
  --red-soft: #faedeb;
  --blue: #4e79aa;
  --blue-soft: #eaf2fb;
  --shadow: 0 18px 55px rgb(26 55 91 / 9%);
  --radius: 12px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgb(57 108 169 / 25%);
  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-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  position: relative;
  background: radial-gradient(ellipse at 50% 0%, #eaf3ff 0, var(--page) 46%, var(--page) 100%);
}
.login-card {
  width: min(100%, 420px);
  padding: 42px 44px 40px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 88px;
  height: 42px;
  display: block;
  flex: 0 0 auto;
  border-radius: 5px;
  background: #fff;
  object-fit: contain;
}
.brand-mark-large { width: 172px; height: 81px; border-radius: 8px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 10px; font-weight: 750; letter-spacing: .12em; line-height: 1.35; }
.login-card h1 { margin: 0; font-size: 27px; line-height: 1.2; letter-spacing: -.045em; font-weight: 680; }
.login-description { margin: 10px 0 28px; color: var(--muted); font-size: 14px; }
.login-footnote { position: absolute; bottom: 20px; margin: 0; color: var(--soft-muted); font-size: 11px; }
.form-stack { display: grid; gap: 9px; }
.form-stack label, .field { color: #3e526e; font-size: 12px; font-weight: 650; }
.form-stack label:not(:first-child) { margin-top: 9px; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 450;
  transition: border-color .16s ease, box-shadow .16s ease;
}
input::placeholder, textarea::placeholder { color: #9ba69f; }
input:focus, select:focus, textarea:focus { border-color: #6b95c6; box-shadow: 0 0 0 3px rgb(57 108 169 / 10%); outline: none; }
textarea { min-height: 82px; resize: vertical; }

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}
.button:active { transform: translateY(1px); }
.button-primary { background: var(--green); color: white; }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { border-color: #c8d8ea; background: var(--green-soft); color: var(--green-dark); }
.button-secondary:hover { border-color: #a9c4e1; background: #e5f0fc; }
.button-quiet { border-color: var(--line); background: white; color: #53657e; }
.button-quiet:hover { border-color: var(--line-strong); background: #f8fbff; }
.button-full { width: 100%; min-height: 44px; margin-top: 12px; font-size: 13px; }
.text-button { border: 0; padding: 4px 2px; background: transparent; color: var(--green); font-size: 12px; font-weight: 650; cursor: pointer; }
.text-button:hover { color: var(--green-dark); text-decoration: underline; }
.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px;
  background: transparent;
  color: #718079;
  cursor: pointer;
}
.icon-button:hover { border-color: var(--line); background: #f7faff; color: var(--ink); }
.icon-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.form-error { margin: 3px 0 0; color: var(--red); font-size: 12px; }

.app-shell { min-height: 100vh; }
.sidebar {
  width: 238px;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  padding: 24px 15px 16px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 8px; padding: 0 9px; color: var(--ink); text-decoration: none; }
.brand-name { font-size: 12px; line-height: 1.25; letter-spacing: -.01em; }
.brand-name strong { color: var(--green); font-size: 13px; font-weight: 720; }
.nav-label { margin: 43px 10px 10px; color: #8b9ab0; font-size: 9px; font-weight: 750; letter-spacing: .13em; }
.primary-nav { display: grid; gap: 4px; }
.nav-link {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 8px;
  padding: 0 11px;
  background: transparent;
  color: #566983;
  font-size: 12px;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
}
.nav-link:hover { background: #f6f8f6; color: var(--ink); }
.nav-link.is-active { background: var(--green-soft); color: var(--green-dark); font-weight: 680; }
.nav-icon { width: 17px; height: 17px; display: inline-grid; place-items: center; color: currentColor; font-size: 15px; line-height: 1; }
.nav-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.mobile-logout { display: none; }
.mobile-contacts { display: none; }
.sidebar-bottom { display: grid; gap: 8px; margin-top: auto; }
.sidebar-user { display: flex; align-items: center; gap: 9px; min-height: 56px; border-top: 1px solid var(--line); padding: 13px 5px 0; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #e8f0fa; color: var(--green); font-size: 11px; font-weight: 750; }
.user-copy { display: grid; min-width: 0; flex: 1; gap: 1px; }
.user-copy strong { font-size: 11px; font-weight: 650; }
.user-copy small { color: var(--muted); font-size: 10px; }
.logout-button { flex: 0 0 auto; }
.main-column { min-height: 100vh; margin-left: 238px; }
.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding: 0 40px; background: rgb(255 255 255 / 88%); }
.topbar-date { color: #718079; font-size: 11px; font-weight: 550; }
.topbar-actions { display: flex; gap: 9px; }
.page-content { width: min(100%, 1370px); margin: 0 auto; padding: 33px 40px 56px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.page-heading h1 { margin: 0; font-size: 28px; line-height: 1.2; letter-spacing: -.045em; font-weight: 680; }
.page-description { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.summary-item { min-height: 112px; border: 1px solid var(--line); border-radius: var(--radius); padding: 17px 17px 15px; background: white; text-align: left; cursor: pointer; transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease; }
.summary-item:hover { transform: translateY(-1px); border-color: #bfd1e3; box-shadow: 0 7px 22px rgb(26 55 91 / 5%); }
.summary-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.summary-label { color: #6b7b72; font-size: 11px; font-weight: 600; }
.summary-mark { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 750; }
.summary-item[data-tone="amber"] .summary-mark { background: var(--amber-soft); color: var(--amber); }
.summary-item[data-tone="red"] .summary-mark { background: var(--red-soft); color: var(--red); }
.summary-item[data-tone="blue"] .summary-mark { background: var(--blue-soft); color: var(--blue); }
.summary-count { display: block; margin-top: 7px; font-size: 26px; line-height: 1; letter-spacing: -.055em; font-weight: 690; }
.summary-hint { display: block; margin-top: 7px; color: #8a968e; font-size: 10px; }
.dashboard-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.dashboard-panel { min-height: 202px; overflow: hidden; }
.dashboard-wide { grid-column: 1 / -1; }
.panel-heading { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #e8eef5; padding: 14px 17px; }
.panel-heading h2 { margin: 0; font-size: 13px; line-height: 1.3; font-weight: 680; letter-spacing: -.015em; }
.panel-heading p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.count-badge { min-width: 26px; height: 26px; display: inline-grid; place-items: center; border-radius: 8px; background: #f1f5fa; color: #58685f; font-size: 11px; font-weight: 700; }
.compact-list { padding: 0 17px; }
.compact-row { width: 100%; min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 0; border-bottom: 1px solid #e9eff6; padding: 9px 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.compact-row:last-child { border-bottom: 0; }
.compact-main { min-width: 0; display: grid; gap: 2px; }
.compact-title { overflow: hidden; color: #203a5d; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.compact-meta { overflow: hidden; color: #8492a5; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.compact-due { flex: 0 0 auto; color: #72829a; font-size: 10px; font-weight: 600; text-align: right; }
.compact-due.is-late { color: var(--red); }
.compact-empty { padding: 20px 0; color: #8290a3; font-size: 11px; text-align: center; }

.table-panel { overflow: hidden; }
.list-toolbar { display: flex; align-items: center; gap: 9px; min-height: 64px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.search-field { min-width: 190px; max-width: 380px; flex: 1; position: relative; }
.search-field svg { width: 16px; height: 16px; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); fill: none; stroke: #8192a8; stroke-width: 1.7; stroke-linecap: round; }
.search-field input { height: 37px; min-height: 37px; padding: 7px 10px 7px 34px; border-color: var(--line); background: #fbfdff; font-size: 11px; }
.filter-field { flex: 0 0 auto; }
.filter-field select { width: auto; min-width: 126px; height: 37px; min-height: 37px; padding: 7px 27px 7px 10px; border-color: var(--line); background-color: white; font-size: 11px; }
.table-scroll { width: 100%; overflow-x: auto; }
.letter-table { width: 100%; min-width: 850px; border-collapse: collapse; }
.letter-table th { height: 39px; padding: 0 13px; background: #fbfdff; color: #8291a5; font-size: 9px; font-weight: 700; letter-spacing: .035em; text-align: left; white-space: nowrap; }
.letter-table td { height: 63px; border-top: 1px solid #e8eef5; padding: 9px 13px; color: #53647b; font-size: 10px; vertical-align: middle; }
.letter-table tbody tr:hover { background: #f7faff; }
.letter-table th:first-child, .letter-table td:first-child { padding-left: 18px; }
.letter-table th:last-child, .letter-table td:last-child { padding-right: 16px; text-align: right; }
.letter-title-cell { display: grid; max-width: 275px; gap: 3px; }
.letter-title-cell strong { overflow: visible; overflow-wrap: anywhere; color: #203956; font-size: 11px; font-weight: 650; line-height: 1.4; white-space: normal; }
.letter-title-cell span { overflow: hidden; color: #8997aa; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.item-number-cell { width: 64px; color: #617b9c; font-variant-numeric: tabular-nums; }
.letter-row.is-editing > td { background: #dceeff; }
.letter-row.is-editing > td:first-child { box-shadow: inset 3px 0 0 #4c93d8; }
.status-pill, .type-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 8px; background: #f1f4f2; color: #61738d; font-size: 9px; font-weight: 650; line-height: 1.2; white-space: nowrap; }
.status-pill::before { width: 5px; height: 5px; border-radius: 50%; background: currentColor; content: ""; }
.status-pill[data-status="Approved"], .status-pill[data-status="Completed"] { background: var(--green-soft); color: #3e7758; }
.status-pill[data-status="Approved with comment"] { background: var(--blue-soft); color: var(--blue); }
.status-pill[data-status="Resubmit"] { background: var(--amber-soft); color: var(--amber); }
.status-pill[data-status="Under Review"] { background: var(--amber-soft); color: var(--amber); }
.status-pill[data-status="Rejected"], .status-pill[data-status="Cancelled"] { background: var(--red-soft); color: var(--red); }
.status-pill[data-status="On Hold"] { background: #f3eff8; color: #76618e; }
.type-pill { background: #f3f6fb; color: #61738d; }
.due-cell { white-space: nowrap; }
.due-cell.is-late { color: var(--red); font-weight: 650; }
.row-action { border: 0; padding: 5px 7px; background: transparent; color: var(--green); font-size: 10px; font-weight: 650; cursor: pointer; }
.row-action:hover { text-decoration: underline; }
.row-action.is-muted { color: #7d8ca2; }
.empty-state { padding: 48px 20px; color: var(--muted); text-align: center; }
.empty-icon { width: 35px; height: 35px; display: grid; place-items: center; margin: 0 auto 9px; border-radius: 11px; background: #f1f6fc; color: #7991ac; font-size: 16px; }
.empty-state strong { display: block; color: #3e526e; font-size: 12px; }
.empty-state p { margin: 5px 0 0; font-size: 10px; }
.loading-row { padding: 24px; color: #8291a5; font-size: 11px; text-align: center; }

.modal-dialog { width: min(700px, calc(100vw - 28px)); max-width: none; max-height: min(90vh, 900px); overflow: auto; border: 1px solid var(--line); border-radius: 14px; padding: 0; background: white; color: var(--ink); box-shadow: 0 24px 85px rgb(16 41 72 / 20%); }
.modal-dialog::backdrop { background: rgb(14 31 23 / 45%); backdrop-filter: blur(2px); }
.modal-dialog-small { width: min(450px, calc(100vw - 28px)); }
.modal-content { display: grid; gap: 17px; padding: 24px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.modal-heading h2 { margin: 0; font-size: 20px; line-height: 1.2; letter-spacing: -.035em; font-weight: 680; }
.modal-heading .eyebrow { margin-bottom: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 15px; }
.field { min-width: 0; display: grid; gap: 6px; }
.field-full { grid-column: 1 / -1; }
.field input, .field select, .field textarea { font-size: 12px; }
.inline-field { display: flex; align-items: center; gap: 9px; }
.inline-field select { flex: 1; }
.due-date-note { color: #87948b; font-size: 10px; font-weight: 450; }
.reply-actions { display: grid; gap: 12px; border: 1px solid #d8e5f3; border-radius: 10px; padding: 14px; background: #f7faff; }
.reply-actions strong { color: #294666; font-size: 11px; }
.reply-actions p { margin: 3px 0 0; color: #75859d; font-size: 10px; }
.reply-action-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }
.reply-date-field, .related-reply-field { min-width: 150px; flex: 1; }
.reply-action-controls .button { margin-left: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 13px; border-top: 1px solid var(--line); }
.toast { max-width: min(400px, calc(100vw - 32px)); position: fixed; right: 22px; bottom: 22px; z-index: 10; transform: translateY(12px); border: 1px solid #d1deed; border-radius: 9px; padding: 11px 15px; background: #fff; color: #304766; box-shadow: 0 10px 30px rgb(26 55 91 / 10%); font-size: 11px; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast[data-tone="error"] { border-color: #edcfcc; color: var(--red); }

.not-found-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.not-found-content { width: min(100%, 480px); text-align: center; }
.not-found-content .brand-mark { margin: 0 auto 25px; }
.not-found-content h1 { margin: 0; font-size: 29px; letter-spacing: -.045em; line-height: 1.18; }
.not-found-content .page-description { margin: 10px 0 23px; }

@media (max-width: 1120px) {
  .sidebar { width: 215px; }
  .brand .brand-mark { width: 76px; height: 36px; }
  .brand-name { font-size: 11px; }
  .main-column { margin-left: 215px; }
  .topbar { padding: 0 28px; }
  .page-content { padding: 30px 28px 48px; }
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .sidebar { width: auto; height: auto; position: sticky; inset: 0 0 auto; display: block; padding: 11px 15px 9px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { width: max-content; padding: 0 2px 10px; }
  .brand .brand-mark { width: 92px; height: 44px; border-radius: 5px; }
  .brand-name br { display: none; }
  .brand-name strong::before { content: " "; }
  .nav-label, .sidebar-bottom { display: none; }
  .primary-nav { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; }
  .primary-nav::-webkit-scrollbar { display: none; }
  .nav-link { width: auto; min-width: max-content; min-height: 35px; gap: 7px; padding: 0 10px; font-size: 10px; }
  .nav-icon { width: 15px; height: 15px; font-size: 13px; }
  .nav-icon svg { width: 15px; height: 15px; }
  .mobile-contacts { display: flex; }
  .mobile-logout { display: flex; }
  .main-column { min-height: calc(100vh - 88px); margin-left: 0; }
  .topbar { height: 55px; padding: 0 20px; }
  .page-content { padding: 26px 20px 42px; }
}

@media (max-width: 620px) {
  .login-card { padding: 32px 25px 28px; }
  .topbar-date { font-size: 10px; }
  .topbar .button { min-height: 35px; padding: 7px 9px; font-size: 10px; }
  .page-content { padding: 23px 14px 32px; }
  .page-heading { align-items: flex-start; margin-bottom: 19px; }
  .page-heading > .button { align-self: flex-start; min-width: max-content; }
  .page-heading h1 { font-size: 24px; }
  .page-description { max-width: 330px; font-size: 11px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .summary-item { min-height: 99px; padding: 13px; }
  .summary-label { font-size: 10px; }
  .summary-count { font-size: 23px; }
  .dashboard-columns { grid-template-columns: 1fr; gap: 10px; }
  .dashboard-wide { grid-column: auto; }
  .list-toolbar { align-items: stretch; flex-wrap: wrap; padding: 11px; }
  .search-field { max-width: none; flex-basis: 100%; }
  .filter-field { flex: 1 1 calc(50% - 6px); }
  .filter-field select { width: 100%; min-width: 0; }
  .letter-table { min-width: 780px; }
  .modal-content { gap: 14px; padding: 18px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .field-full { grid-column: auto; }
  .reply-action-controls { align-items: stretch; }
  .reply-action-controls .button { margin-left: 0; }
  .toast { right: 12px; bottom: 12px; }
}

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