@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap');

:root {
  --ink: #202737;
  --muted: #70798a;
  --soft: #f2f4f8;
  --line: #dde2eb;
  --paper: #ffffff;
  --forest: #202a44;
  --forest-2: #344465;
  --mint: #e7ebf7;
  --coral: #ff7252;
  --coral-dark: #e85e40;
  --sand: #f5ead8;
  --blue: #dce9f3;
  --danger: #b73939;
  --sidebar: 260px;
  --radius: 16px;
  --shadow: 0 10px 32px rgba(31, 48, 40, .075);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { margin: 0; min-height: 100%; color: var(--ink); background: #f5f6f3; font-family: "DM Sans", Arial, sans-serif; font-size: 15px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Manrope", "DM Sans", Arial, sans-serif; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; width: var(--sidebar); padding: 28px 20px 22px; color: #eaf3ef; background: var(--forest); flex-direction: column; }
.brand { display: flex; min-width: 0; align-items: center; gap: 12px; }
.brand > span:last-child { display: flex; min-width: 0; flex-direction: column; }
.brand strong { color: #fff; font-family: "Manrope", sans-serif; font-size: 17px; letter-spacing: -.3px; }
.brand small { overflow: hidden; max-width: 165px; margin-top: 1px; color: #9db6ac; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { display: grid; width: 48px; height: 48px; border-radius: 14px; color: #fff; background: var(--coral); font-family: "Manrope", sans-serif; font-size: 16px; font-weight: 800; letter-spacing: -.4px; place-items: center; box-shadow: 0 8px 18px rgba(255, 112, 71, .2); }
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; font-size: 13px; }
.main-nav { display: flex; margin-top: 42px; flex-direction: column; gap: 6px; }
.nav-label { margin: 0 12px 9px; color: #819d92; font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
.nav-item { display: flex; padding: 11px 13px; border-radius: 10px; color: #b8ccc4; align-items: center; gap: 12px; transition: .18s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-item.active { color: #fff; background: #285446; font-weight: 600; }
.nav-item.active::after { width: 5px; height: 5px; margin-left: auto; border-radius: 50%; background: var(--coral); content: ""; }
.nav-symbol { display: grid; width: 22px; color: #d5e2dd; font-size: 18px; text-align: center; place-items: center; }
.sidebar-bottom { margin-top: auto; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.1); }
.profile-chip { display: flex; min-width: 0; align-items: center; gap: 10px; }
.profile-chip > span:nth-child(2) { display: flex; min-width: 0; flex-direction: column; }
.profile-chip strong { overflow: hidden; color: #fff; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.profile-chip small { color: #90aa9f; font-size: 11px; }
.avatar { display: grid; width: 36px; height: 36px; border-radius: 10px; color: var(--forest); background: #d7e8e0; font-size: 11px; font-weight: 800; flex: 0 0 auto; place-items: center; }
.logout-link { display: flex; margin-top: 17px; color: #9db6ac; font-size: 12px; justify-content: space-between; }
.logout-link:hover { color: #fff; }

.app-main { min-width: 0; margin-left: var(--sidebar); flex: 1; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; height: 76px; padding: 0 38px; border-bottom: 1px solid #e7ebe8; background: rgba(247,248,246,.95); align-items: center; justify-content: space-between; backdrop-filter: blur(12px); }
.breadcrumbs { display: flex; color: #89928d; font-size: 12px; align-items: center; gap: 9px; }
.breadcrumbs i { color: #c4cbc7; font-style: normal; }
.breadcrumbs strong { color: #435149; font-weight: 600; }
.top-actions, .heading-actions { display: flex; align-items: center; gap: 10px; }
.content { width: min(1460px, 100%); margin: 0 auto; padding: 36px 40px 64px; }
.menu-toggle { display: none !important; }

.button { display: inline-flex; min-height: 42px; padding: 0 16px; border: 1px solid transparent; border-radius: 10px; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 700; line-height: 1; transition: transform .15s ease, background .15s ease, border .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--coral); box-shadow: 0 6px 15px rgba(255,112,71,.17); }
.button-primary:hover { background: var(--coral-dark); }
.button-secondary { color: #fff; background: var(--forest); }
.button-secondary:hover { background: var(--forest-2); }
.button-ghost { color: #405048; border-color: #d9dfdb; background: #fff; }
.button-ghost:hover { border-color: #bfc9c3; }
.button-wide { width: 100%; }
.icon-button { display: grid; width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; place-items: center; }
.theme-toggle { color: var(--ink); font-size: 17px; }
.floating-theme { position: fixed; top: 20px; right: 20px; z-index: 100; box-shadow: var(--shadow); }
kbd { padding: 3px 6px; border: 1px solid #dfe4e1; border-radius: 5px; color: #8b948f; background: #f4f6f4; font-family: inherit; font-size: 9px; }

.page-heading, .case-header, .editor-heading { display: flex; margin-bottom: 28px; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-heading h1, .case-header h1, .editor-heading h1, .search-page h1 { margin-bottom: 7px; font-size: clamp(28px, 3vw, 38px); line-height: 1.12; letter-spacing: -1.35px; }
.page-heading p, .case-header p { margin-bottom: 0; color: var(--muted); }
.page-heading.compact { margin-bottom: 22px; }
.hero-heading { align-items: center; }
.hero-heading h1 { margin-bottom: 4px; }
.eyebrow { margin-bottom: 7px; color: var(--coral-dark) !important; font-size: 10px !important; font-weight: 800; letter-spacing: 1.45px; text-transform: uppercase; }
.date-card { display: flex; min-width: 132px; padding: 13px 17px; border: 1px solid var(--line); border-radius: 13px; background: #fff; align-items: center; gap: 11px; box-shadow: var(--shadow); }
.date-card > span { color: var(--forest); font-family: "Manrope", sans-serif; font-size: 30px; font-weight: 800; line-height: 1; }
.date-card div { padding-left: 11px; border-left: 1px solid var(--line); color: #46544c; font-size: 12px; font-weight: 700; }
.date-card small { display: block; margin-top: 2px; color: #929b96; font-size: 10px; }

.metric-grid { display: grid; margin-bottom: 24px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.metric-card { position: relative; display: flex; min-height: 138px; padding: 22px; overflow: hidden; border: 1px solid #e1e6e2; border-radius: var(--radius); background: #fff; align-items: center; gap: 17px; box-shadow: 0 5px 18px rgba(31, 48, 40, .035); }
.metric-card.accent { border-color: transparent; color: #fff; background: var(--forest); }
.metric-card.accent::after { position: absolute; right: -24px; bottom: -45px; width: 120px; height: 120px; border: 22px solid rgba(255,255,255,.055); border-radius: 50%; content: ""; }
.metric-icon { display: grid; width: 48px; height: 48px; border-radius: 13px; color: #fff; background: rgba(255,255,255,.13); font-size: 21px; flex: 0 0 auto; place-items: center; }
.metric-icon.mint { color: #255344; background: var(--mint); }
.metric-icon.sand { color: #7f5d2a; background: var(--sand); }
.metric-icon.blue { color: #345c7a; background: var(--blue); }
.metric-card div:last-child { display: flex; flex-direction: column; }
.metric-card div:last-child > span { margin-bottom: 4px; color: #76817b; font-size: 11px; font-weight: 700; }
.metric-card.accent div:last-child > span, .metric-card.accent small { color: #a9c2b8; }
.metric-card strong { font-family: "Manrope", sans-serif; font-size: 28px; line-height: 1; }
.metric-card small { margin-top: 7px; color: #9aa29e; font-size: 10px; }

.panel { border: 1px solid #e1e6e2; border-radius: var(--radius); background: #fff; box-shadow: 0 7px 26px rgba(31, 48, 40, .045); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, .85fr); gap: 20px; }
.panel-head { display: flex; padding: 23px 24px 17px; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-head h2 { margin: 0; font-size: 18px; letter-spacing: -.55px; }
.panel-head .eyebrow { margin-bottom: 3px; }
.text-link { color: var(--forest-2); font-size: 12px; font-weight: 700; }
.text-link:hover { color: var(--coral-dark); }
.record-list { padding: 0 12px 12px; }
.record-row { display: flex; min-height: 72px; padding: 10px 12px; border-top: 1px solid #edf0ee; align-items: center; gap: 13px; transition: .16s ease; }
.record-row:hover { border-radius: 10px; background: #f6f8f6; }
.case-badge { display: grid; width: 39px; height: 39px; border-radius: 10px; color: var(--forest); background: var(--mint); font-size: 11px; font-weight: 800; flex: 0 0 auto; place-items: center; }
.record-main { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.record-main strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.record-main small, .record-meta small { margin-top: 3px; color: #8a948e; font-size: 10px; }
.record-meta { display: flex; min-width: 150px; align-items: flex-end; flex-direction: column; }
.row-arrow, .table-arrow { color: #a5aea9; font-size: 24px; }
.quick-panel { padding-bottom: 16px; }
.quick-action { display: flex; margin: 0 16px 9px; padding: 13px; border: 1px solid #e8ece9; border-radius: 12px; align-items: center; gap: 12px; }
.quick-action:hover { border-color: #cbd5cf; background: #f8faf8; }
.quick-action > span { display: grid; width: 36px; height: 36px; border-radius: 9px; color: var(--forest); background: var(--mint); font-size: 17px; place-items: center; }
.quick-action.primary > span { color: #fff; background: var(--coral); }
.quick-action div { display: flex; flex-direction: column; }
.quick-action strong { font-size: 12px; }
.quick-action small { margin-top: 2px; color: #8b958f; font-size: 9.5px; }
.numbering-note { margin: 16px; padding: 16px; border-radius: 12px; background: #f2f6f3; }
.numbering-note span, .numbering-note small { display: block; color: #849089; font-size: 9px; }
.numbering-note strong { display: block; margin: 4px 0; color: var(--forest); font-family: "Manrope", sans-serif; font-size: 17px; }

.status-dot { display: inline-flex; color: #48645a; font-size: 10px; font-weight: 700; align-items: center; gap: 6px; white-space: nowrap; }
.status-dot::before { width: 7px; height: 7px; border-radius: 50%; background: #56a27f; content: ""; box-shadow: 0 0 0 3px #e4f3ec; }
.status-dot.waiting::before { background: #d69b42; box-shadow: 0 0 0 3px #f8eedf; }
.status-dot.closed::before { background: #9aa29e; box-shadow: 0 0 0 3px #ecefed; }
.status-dot.draft::before { background: #6d8fa8; box-shadow: 0 0 0 3px #e8f0f5; }
.status-dot.final::before { background: #694fa0; box-shadow: 0 0 0 3px #eee9f7; }
.status-pill, .count-badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; color: #627168; background: #f0f3f1; font-size: 9px; font-weight: 700; align-items: center; }
.status-pill.success { color: #34715a; background: #e5f2ec; }
.count-badge { margin-left: 5px; }

.filter-bar { display: flex; margin-bottom: 13px; align-items: center; justify-content: space-between; gap: 12px; }
.tabs { display: flex; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: #fff; gap: 2px; }
.tabs a { padding: 8px 14px; border-radius: 8px; color: #738078; font-size: 11px; font-weight: 700; }
.tabs a.active { color: #fff; background: var(--forest); }
.table-panel { overflow: hidden; }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 17px; color: #7d8982; background: #f6f8f6; font-size: 9px; font-weight: 800; letter-spacing: .7px; text-align: left; text-transform: uppercase; }
td { padding: 15px 17px; border-top: 1px solid #edf0ee; color: #536159; font-size: 12px; vertical-align: middle; }
td strong, td small { display: block; }
td strong { color: var(--ink); font-size: 12px; }
td small { margin-top: 3px; color: #929b96; font-size: 9.5px; }
.case-number { color: var(--forest-2); font-family: "Manrope", sans-serif; font-size: 11px; font-weight: 800; white-space: nowrap; }
.empty-inline { padding: 34px; color: #8a958e; text-align: center; }
.empty-inline.tall { min-height: 130px; display: grid; place-items: center; }
.empty-state { padding: 34px 20px 45px; color: #7d8982; text-align: center; }
.empty-state > span { font-size: 28px; }
.empty-state h3 { margin: 10px 0 5px; color: var(--ink); font-size: 16px; }
.empty-state p { margin-bottom: 18px; font-size: 12px; }

label { display: flex; color: #4a5850; font-size: 11px; font-weight: 700; flex-direction: column; gap: 7px; }
input, select, textarea { width: 100%; border: 1px solid #dce2de; border-radius: 9px; outline: none; color: var(--ink); background: #fff; font-size: 13px; transition: border .15s ease, box-shadow .15s ease; }
input, select { height: 43px; padding: 0 12px; }
textarea { min-height: 110px; padding: 11px 12px; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #79a290; box-shadow: 0 0 0 3px rgba(57,105,85,.1); }
input::placeholder, textarea::placeholder { color: #aab2ad; }
label small { color: #929b96; font-size: 9.5px; font-weight: 400; }
.required { margin-left: 4px; color: var(--coral-dark); font-size: 9px; font-weight: 600; }
.form-grid { display: grid; gap: 17px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.span-two { grid-column: span 2; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .7fr); gap: 20px; align-items: start; }
.form-panel, .settings-form { padding: 26px; }
.section-title { display: flex; margin-bottom: 24px; align-items: center; gap: 13px; }
.section-title > span { display: grid; width: 35px; height: 35px; border-radius: 9px; color: var(--forest); background: var(--mint); font-size: 10px; font-weight: 800; place-items: center; }
.section-title h2 { margin: 0; font-size: 16px; }
.section-title p { margin: 2px 0 0; color: #8a948e; font-size: 10px; }
.form-aside { padding: 25px; }
.auto-number { padding: 18px; border: 1px dashed #bacac2; border-radius: 12px; background: #f3f7f4; }
.auto-number small { color: #829087; font-size: 9px; font-weight: 700; text-transform: uppercase; }
.auto-number strong { display: block; margin: 7px 0 12px; color: var(--forest); font-family: "Manrope", sans-serif; font-size: 18px; }
.auto-number p { margin: 0; color: #75827a; font-size: 10px; line-height: 1.5; }
.form-actions { display: flex; margin-top: 24px; gap: 9px; }
.form-actions.right { justify-content: flex-end; }

.heading-line { display: flex; margin-bottom: 10px; color: #89948d; font-size: 10px; align-items: center; gap: 14px; }
.case-header { align-items: center; }
.case-header h1 { max-width: 850px; margin-bottom: 7px; }
.case-id { color: var(--forest-2) !important; font-family: "Manrope", sans-serif; font-size: 13px; font-weight: 800; letter-spacing: .3px; }
.case-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; align-items: start; }
.case-content { display: grid; gap: 18px; }
.detail-grid { display: grid; margin: 0; padding: 4px 24px 24px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 28px; }
.detail-grid div { padding-bottom: 15px; border-bottom: 1px solid #edf0ee; }
.detail-grid dt { margin-bottom: 5px; color: #8a958f; font-size: 9px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; }
.detail-grid dd { margin: 0; font-size: 12px; font-weight: 600; }
.notes-box { margin: 0 24px 24px; padding: 16px; border-left: 3px solid var(--coral); border-radius: 0 10px 10px 0; background: #faf6f2; }
.notes-box strong { font-size: 10px; }
.notes-box p { margin: 5px 0 0; color: #657069; font-size: 11px; line-height: 1.6; }
.sticky-panel { position: sticky; top: 96px; padding: 22px; }
.big-case-number { margin-bottom: 18px; color: var(--forest); font-family: "Manrope", sans-serif; font-size: 17px; font-weight: 800; }
.aside-stat { display: flex; padding: 12px 0; border-top: 1px solid #edf0ee; justify-content: space-between; }
.aside-stat span { color: #849088; font-size: 10px; }
.aside-stat strong { font-size: 11px; }
.sticky-panel hr, .settings-form hr { height: 1px; margin: 17px 0; border: 0; background: #e9edea; }
.sticky-panel .button + .button { margin-top: 8px; }
.document-list { padding: 0 16px 17px; }
.document-list a { display: flex; min-height: 62px; padding: 10px 8px; border-top: 1px solid #edf0ee; align-items: center; gap: 12px; }
.document-list a:hover { background: #f8faf8; }
.document-list a > span:nth-child(2) { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.document-list strong { overflow: hidden; font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.document-list small { margin-top: 3px; color: #8c9690; font-size: 9px; }
.document-list b { color: #a0aaa4; font-size: 20px; font-weight: 400; }
.file-icon { display: grid; width: 40px; height: 40px; border-radius: 9px; color: #3f6078; background: var(--blue); font-size: 8px; font-weight: 800; place-items: center; }
.file-icon.letter { color: #7d5530; background: var(--sand); font-size: 13px; }
.upload-zone { display: flex; margin: 0 24px 18px; padding: 14px; border: 1px dashed #c6d0ca; border-radius: 12px; background: #f8faf8; align-items: center; gap: 12px; }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-zone label { display: flex; min-width: 0; cursor: pointer; flex: 1; align-items: center; flex-direction: row; gap: 10px; }
.upload-zone label > span { display: grid; width: 36px; height: 36px; border-radius: 9px; color: var(--forest); background: var(--mint); font-size: 17px; flex: 0 0 auto; place-items: center; }
.upload-zone label strong, .upload-zone label small { display: block; }
.upload-zone label strong { font-size: 11px; }
.upload-zone label small { margin-top: 2px; color: #8b958f; font-size: 9px; }

.editor-heading { align-items: center; }
.editor-heading h1 { margin: 5px 0 0; font-size: 28px; }
.back-link { color: #718078; font-size: 10px; font-weight: 700; }
.back-link:hover { color: var(--forest); }
.letter-workspace { display: grid; grid-template-columns: minmax(370px, .85fr) minmax(460px, 1.15fr); gap: 20px; align-items: start; }
.editor-panel { overflow: hidden; border: 1px solid #e0e5e1; border-radius: 15px; background: #fff; box-shadow: var(--shadow); }
.editor-toolbar { display: flex; min-height: 58px; padding: 0 20px; border-bottom: 1px solid #e8ece9; color: #7b8780; background: #f8faf8; font-size: 10px; align-items: center; justify-content: space-between; }
.editor-toolbar div { display: flex; align-items: center; gap: 7px; }
.status-indicator { width: 7px; height: 7px; border-radius: 50%; background: #62a887; box-shadow: 0 0 0 3px #e4f3ec; }
.editor-toolbar select { width: auto; height: 33px; padding-right: 30px; font-size: 10px; }
.editor-scroll { max-height: calc(100vh - 255px); overflow-y: auto; }
.form-section { padding: 23px; border-bottom: 1px solid #edf0ee; }
.form-section > label + label { margin-top: 15px; }
.letter-textarea { min-height: 360px; font-family: Georgia, serif; font-size: 13px; line-height: 1.7; }
.editor-actions { display: flex; padding: 15px 20px; background: #fff; justify-content: flex-end; gap: 9px; }
.paper-preview-wrap { padding: 15px 22px 26px; border: 1px solid var(--line); border-radius: 15px; background: #e6e9ef; }
.preview-label { display: flex; margin-bottom: 10px; color: #6d7a72; font-size: 9px; font-weight: 800; letter-spacing: .8px; justify-content: space-between; text-transform: uppercase; }
.paper-preview { position: relative; width: min(100%, 720px); aspect-ratio: 210 / 297; margin: 0 auto; padding: 6.5% 8.4% 10% 9.1%; overflow: hidden; color: #292929; background: #fff; font-family: Georgia, "Times New Roman", serif; font-size: clamp(6px, .68vw, 10px); line-height: 1.58; box-shadow: 0 12px 34px rgba(24,31,48,.14); }
.classic-preview-header { display: flex; margin-bottom: 8%; padding-bottom: 3.5%; border-bottom: 2px solid #333; align-items: flex-start; justify-content: space-between; }
.classic-preview-header h2 { max-width: 60%; margin: 0; color: #222; font-family: Arial, sans-serif; font-size: 1.75em; font-weight: 600; line-height: 1.15; }
.classic-preview-contact { max-width: 34%; color: #666; font-family: Arial, sans-serif; font-size: .62em; line-height: 1.55; text-align: right; }
.paper-sender { display: block; margin-bottom: 2%; color: #777; font-family: Arial, sans-serif; font-size: .55em; text-decoration: underline; }
.paper-address { display: flex; min-height: 17%; flex-direction: column; }
.paper-address span { min-height: 1.5em; }
.paper-address b { font-weight: 400; }
.classic-paper-meta { margin: 1% 0 6%; color: #555; font-family: Arial, sans-serif; font-size: .66em; text-align: right; }
.classic-paper-meta div { margin-top: 1%; }
.classic-paper-meta span { display: inline-block; width: 24%; color: #888; text-align: left; }
.classic-paper-meta strong { display: inline-block; width: 38%; color: #333; font-weight: 500; text-align: left; }
.paper-preview h3 { max-width: 92%; margin: 0 0 5%; color: #222; font-size: 1.25em; font-weight: 700; line-height: 1.35; }
.paper-body { white-space: normal; }
.paper-preview footer { position: absolute; right: 8.4%; bottom: 4.7%; left: 9.1%; padding-top: 1.7%; border-top: 1px solid #aaa; color: #777; font-family: Arial, sans-serif; font-size: .56em; text-align: center; }

.settings-layout { display: grid; margin-bottom: 20px; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.settings-form .panel-head { padding: 0 0 23px; }
.settings-aside .panel { padding: 22px; }
.mini-letter { position: relative; aspect-ratio: 210 / 297; padding: 22px; overflow: hidden; border: 1px solid #e5e9ef; background: #fff; box-shadow: 0 9px 22px rgba(31,38,61,.1); }
.mini-letter .mini-accent { width: 100%; height: 2px; margin: 10px 0 18px; background: #444; }
.mini-letter h3 { margin: 3px 0 0; color: #222; font-family: Georgia, serif; font-size: 14px; font-weight: 600; line-height: 1.1; }
.mini-letter .mini-line { display: block; width: 68%; height: 5px; margin: 7px 0; border-radius: 5px; background: #e8eaf0; }
.mini-letter .mini-line.short { width: 44%; }
.mini-letter strong { display: block; margin-top: 28px; padding: 8px 0; border-top: 1px solid #e5e9e6; border-bottom: 1px solid #e5e9e6; color: var(--forest); font-size: 9px; }
.mini-letter p { margin-top: 24px; color: #7d8982; font-size: 8px; line-height: 1.6; }
.theme-info { margin-top: 18px; }
.theme-info h3 { margin-bottom: 7px; font-size: 15px; }
.theme-info p { color: var(--muted); font-size: 10px; line-height: 1.55; }
.users-panel { padding-bottom: 24px; }
.users-grid { display: grid; padding: 0 24px; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 26px; }
.user-list { border: 1px solid #e6ebe7; border-radius: 12px; }
.user-row { display: flex; min-height: 62px; padding: 10px 13px; border-top: 1px solid #edf0ee; align-items: center; gap: 11px; }
.user-row:first-child { border-top: 0; }
.user-row > span:nth-child(2) { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.user-row strong { font-size: 11px; }
.user-row small { color: #8d9791; font-size: 9px; }
.compact-form { padding: 18px; border-radius: 12px; background: #f4f7f5; }
.compact-form h3 { margin-bottom: 16px; font-size: 14px; }
.compact-form .button { margin-top: 16px; }

.search-page { max-width: 950px; margin: 30px auto; }
.big-search { display: flex; margin: 25px 0; padding: 8px 8px 8px 16px; border: 1px solid #dbe2dd; border-radius: 14px; background: #fff; align-items: center; gap: 10px; box-shadow: var(--shadow); }
.big-search > span { color: #75827a; font-size: 23px; }
.big-search input { height: 44px; padding: 0; border: 0; box-shadow: none; flex: 1; }
.result-count { color: #7f8a83; font-size: 11px; }

.alert { margin-bottom: 17px; padding: 13px 15px; border: 1px solid #c9dfd4; border-radius: 10px; color: #35634f; background: #eaf4ef; font-size: 11px; }
.alert-error { border-color: #e9c6c6; color: #913a3a; background: #fbefef; }
.alert ul { margin: 7px 0 0; padding-left: 18px; }

.login-body, .installer-body { min-height: 100vh; background: #edf1ee; }
.login-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(370px, .9fr) minmax(470px, 1.1fr); }
.login-brand { position: relative; display: flex; padding: 8vh 8vw; overflow: hidden; color: #fff; background: var(--forest); justify-content: center; flex-direction: column; }
.login-brand::after { position: absolute; right: -130px; bottom: -170px; width: 440px; height: 440px; border: 70px solid rgba(255,255,255,.035); border-radius: 50%; content: ""; }
.login-brand .brand-mark { position: absolute; top: 7vh; left: 8vw; }
.login-brand .eyebrow { color: #e3ad9a !important; }
.login-brand h1, .installer-intro h1 { max-width: 560px; margin: 0 0 20px; font-size: clamp(34px, 4vw, 58px); line-height: 1.07; letter-spacing: -2.3px; }
.login-brand > p:not(.eyebrow), .installer-intro > p:not(.eyebrow) { max-width: 480px; color: #aec3ba; font-size: 15px; line-height: 1.7; }
.login-quote { position: absolute; bottom: 7vh; left: 8vw; color: #88a399; font-size: 11px; }
.login-card { display: flex; width: min(440px, calc(100% - 50px)); margin: auto; padding: 42px; border: 1px solid #e1e6e2; border-radius: 19px; background: #fff; box-shadow: 0 20px 60px rgba(31,48,40,.1); flex-direction: column; }
.login-card h2 { margin-bottom: 7px; font-size: 27px; letter-spacing: -.9px; }
.muted { color: #7d8982; font-size: 12px; }
.stack-form { display: grid; margin-top: 18px; gap: 16px; }
.stack-form .button { margin-top: 5px; }
.security-note { margin: 20px 0 0; color: #9aa39e; font-size: 9px; text-align: center; }
.mobile-brand { display: none; }

.installer-shell { display: grid; width: min(1280px, calc(100% - 40px)); min-height: 100vh; margin: 0 auto; padding: 45px 0; grid-template-columns: minmax(360px,.75fr) minmax(600px,1.25fr); gap: 45px; align-items: center; }
.installer-intro { position: sticky; top: 50px; padding: 20px; }
.installer-intro .brand-mark { margin-bottom: 50px; }
.installer-intro h1 { color: var(--forest); font-size: clamp(36px, 4vw, 54px); }
.installer-intro > p:not(.eyebrow) { color: #65736b; }
.feature-checks { margin: 35px 0 0; padding: 0; list-style: none; }
.feature-checks li { margin: 11px 0; color: #43534b; font-size: 12px; }
.feature-checks li::before { display: inline-grid; width: 22px; height: 22px; margin-right: 10px; border-radius: 7px; color: var(--forest); background: var(--mint); content: "✓"; font-weight: 800; place-items: center; }
.installer-card { padding: 34px; border: 1px solid #e0e5e1; border-radius: 20px; background: #fff; box-shadow: 0 20px 65px rgba(31,48,40,.1); }
.card-heading { display: flex; margin-bottom: 22px; align-items: flex-start; justify-content: space-between; }
.card-heading h2 { margin: 0; font-size: 24px; }
.installer-form { display: grid; gap: 23px; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { width: 100%; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid #e9edea; color: var(--forest); font-family: "Manrope", sans-serif; font-size: 12px; font-weight: 800; }
.check-row { display: flex; margin-top: 15px; align-items: center; flex-direction: row; gap: 9px; }
.check-row input { width: 16px; height: 16px; }
.admin-db-fields { margin-top: 14px; padding: 15px; border-radius: 10px; background: #f4f7f5; }
.form-note { margin: -12px 0 0; color: #929c96; font-size: 9px; text-align: center; }
.success-panel { padding: 60px 30px; text-align: center; }
.success-icon { display: grid; width: 60px; height: 60px; margin: 0 auto 23px; border-radius: 18px; color: #fff; background: #4b9a75; font-size: 26px; place-items: center; }
.success-panel h2 { margin-bottom: 8px; font-size: 28px; }
.success-panel p:not(.eyebrow) { max-width: 420px; margin: 0 auto 25px; color: #738078; font-size: 12px; }

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf0f7;
  --muted: #9ca5b5;
  --soft: #151a24;
  --line: #2c3442;
  --paper: #171c25;
  --forest: #a8b6e7;
  --forest-2: #c6d0f0;
  --mint: #25314a;
  --sand: #342c25;
  --blue: #203247;
  --shadow: 0 14px 38px rgba(0, 0, 0, .23);
}
html[data-theme="dark"] body { background: #0d1118; }
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .login-brand { background: #0a101a; }
html[data-theme="dark"] .nav-item.active { background: #1d2940; }
html[data-theme="dark"] .topbar { border-color: #252c38; background: rgba(13, 17, 24, .93); }
html[data-theme="dark"] .breadcrumbs { color: #778194; }
html[data-theme="dark"] .breadcrumbs i { color: #485165; }
html[data-theme="dark"] .breadcrumbs strong { color: #cbd2df; }
html[data-theme="dark"] .panel,
html[data-theme="dark"] .metric-card:not(.accent),
html[data-theme="dark"] .date-card,
html[data-theme="dark"] .button-ghost,
html[data-theme="dark"] .icon-button,
html[data-theme="dark"] .tabs,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .installer-card,
html[data-theme="dark"] .big-search,
html[data-theme="dark"] .editor-panel { border-color: #29313e; background: #171c25; }
html[data-theme="dark"] .metric-card.accent { background: #1b2638; }
html[data-theme="dark"] .button-ghost { color: #d2d8e4; }
html[data-theme="dark"] .button-ghost:hover { border-color: #4a5669; background: #202631; }
html[data-theme="dark"] .button-secondary { color: #fff; background: #2b3855; }
html[data-theme="dark"] .button-secondary:hover { background: #354464; }
html[data-theme="dark"] kbd { border-color: #343c49; color: #9ca5b5; background: #11161e; }
html[data-theme="dark"] .date-card div { border-color: #303846; color: #cbd1dc; }
html[data-theme="dark"] .record-row,
html[data-theme="dark"] .document-list a,
html[data-theme="dark"] .user-row,
html[data-theme="dark"] td,
html[data-theme="dark"] .detail-grid div,
html[data-theme="dark"] .aside-stat { border-color: #282f3a; }
html[data-theme="dark"] .record-row:hover,
html[data-theme="dark"] .document-list a:hover { background: #1d232d; }
html[data-theme="dark"] .quick-action { border-color: #2a323f; }
html[data-theme="dark"] .quick-action:hover { border-color: #465165; background: #1d232d; }
html[data-theme="dark"] .numbering-note,
html[data-theme="dark"] .auto-number,
html[data-theme="dark"] .compact-form,
html[data-theme="dark"] .admin-db-fields { border-color: #344052; background: #111720; }
html[data-theme="dark"] th { color: #8f99ab; background: #11161e; }
html[data-theme="dark"] td { color: #b4bdca; }
html[data-theme="dark"] td strong { color: #edf0f7; }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { border-color: #323b49; color: #e9edf5; background: #11161e; }
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus { border-color: #7183b7; box-shadow: 0 0 0 3px rgba(113, 131, 183, .16); }
html[data-theme="dark"] .notes-box { color: #d6dae4; background: #231c1c; }
html[data-theme="dark"] .editor-toolbar,
html[data-theme="dark"] .editor-actions { border-color: #29313e; background: #121821; }
html[data-theme="dark"] .form-section { border-color: #29313e; }
html[data-theme="dark"] .paper-preview-wrap { border-color: #2a3341; background: #11161e; }
html[data-theme="dark"] .preview-label { color: #8e98a9; }
html[data-theme="dark"] .settings-form hr,
html[data-theme="dark"] .sticky-panel hr { background: #2b3340; }
html[data-theme="dark"] .login-body,
html[data-theme="dark"] .installer-body { background: #0d1118; }
html[data-theme="dark"] .installer-intro h1 { color: #edf0f7; }
html[data-theme="dark"] .installer-intro > p:not(.eyebrow),
html[data-theme="dark"] .feature-checks li { color: #aeb7c5; }
html[data-theme="dark"] legend { border-color: #2b3340; color: #cbd4f2; }
html[data-theme="dark"] .alert { border-color: #2f5c49; color: #a9dac2; background: #14251e; }
html[data-theme="dark"] .alert-error { border-color: #643838; color: #f0b1b1; background: #2a1818; }
html[data-theme="dark"] .status-pill.success { color: #a9dac2; background: #193126; }
html[data-theme="dark"] .mini-letter { border-color: #394151; }
html[data-theme="dark"] .theme-info { background: #171c25; }
html[data-theme="dark"] .sidebar-backdrop { background: rgba(3, 6, 10, .7); }

.sidebar-backdrop { display: none; }

@media (max-width: 1100px) {
  :root { --sidebar: 225px; }
  .content { padding-inline: 26px; }
  .topbar { padding-inline: 26px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .quick-panel { display: grid; grid-template-columns: repeat(3, 1fr); }
  .quick-panel .panel-head, .quick-panel .numbering-note { grid-column: 1 / -1; }
  .quick-action { margin: 0 6px 8px; }
  .letter-workspace { grid-template-columns: minmax(340px,.8fr) minmax(400px,1.2fr); }
  .installer-shell { grid-template-columns: minmax(300px,.65fr) minmax(520px,1.35fr); gap: 20px; }
}

@media (max-width: 860px) {
  .sidebar { width: 260px; transform: translateX(-100%); transition: transform .22s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 25; display: block; pointer-events: none; opacity: 0; background: rgba(13,29,23,.45); transition: opacity .22s ease; }
  body.sidebar-open .sidebar-backdrop { pointer-events: auto; opacity: 1; }
  .app-main { margin-left: 0; }
  .menu-toggle { display: grid !important; }
  .breadcrumbs { display: none; }
  .topbar { padding-inline: 20px; }
  .content { padding: 28px 20px 55px; }
  .form-layout, .case-layout, .settings-layout { grid-template-columns: 1fr; }
  .case-aside { order: -1; }
  .sticky-panel { position: static; display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
  .sticky-panel .eyebrow, .sticky-panel .big-case-number, .sticky-panel hr, .sticky-panel .button { grid-column: 1 / -1; }
  .aside-stat { border: 1px solid #edf0ee; border-radius: 9px; padding: 10px; }
  .letter-workspace { grid-template-columns: 1fr; }
  .paper-preview-wrap { order: -1; }
  .paper-preview { max-height: 72vh; }
  .editor-scroll { max-height: none; }
  .installer-shell { display: block; padding: 28px 0; }
  .installer-intro { position: static; padding: 10px 10px 30px; }
  .installer-intro .brand-mark { margin-bottom: 30px; }
  .installer-intro h1 { font-size: 38px; }
  .installer-card { padding: 28px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-card { margin: 8vh auto; }
  .mobile-brand { display: flex; margin-bottom: 35px; color: var(--forest); font-family: "Manrope", sans-serif; font-weight: 800; align-items: center; gap: 10px; }
}

@media (max-width: 620px) {
  .topbar { height: 68px; }
  .top-actions .button { padding: 0 12px; }
  .hide-mobile { display: none; }
  .content { padding-inline: 15px; }
  .page-heading, .case-header, .editor-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button, .heading-actions .button { flex: 1; }
  .hero-heading { flex-direction: row; align-items: center; }
  .hero-heading h1 { font-size: 28px; }
  .hero-heading .date-card { display: none; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 115px; padding: 15px; align-items: flex-start; flex-direction: column; gap: 11px; }
  .metric-icon { width: 35px; height: 35px; border-radius: 9px; font-size: 15px; }
  .metric-card strong { font-size: 23px; }
  .quick-panel { display: block; }
  .quick-action { margin: 0 15px 9px; }
  .record-meta { display: none; }
  .panel-head { padding-inline: 17px; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .tabs { overflow-x: auto; }
  .tabs a { flex: 1; text-align: center; }
  .form-grid.two, .detail-grid, .users-grid { grid-template-columns: 1fr; }
  .span-two { grid-column: span 1; }
  .form-panel, .settings-form, .form-aside { padding: 19px; }
  .detail-grid { padding-inline: 18px; }
  .upload-zone { margin-inline: 17px; align-items: stretch; flex-direction: column; }
  .upload-zone .button { width: 100%; }
  .sticky-panel { display: block; }
  .aside-stat { margin-top: 7px; }
  .paper-preview-wrap { padding: 10px; }
  .paper-preview { font-size: 6px; }
  .editor-heading .heading-actions { width: 100%; }
  .editor-actions { flex-direction: column-reverse; }
  .editor-actions .button { width: 100%; }
  .big-search { align-items: stretch; flex-wrap: wrap; }
  .big-search input { min-width: 0; }
  .big-search .button { width: 100%; }
  .installer-card { padding: 20px; border-radius: 14px; }
  .installer-intro h1 { font-size: 32px; }
  .login-card { width: calc(100% - 28px); padding: 28px 22px; }
}

@media print {
  .sidebar, .topbar, .heading-actions, .button, .sidebar-backdrop { display: none !important; }
  .app-main { margin: 0; }
  .content { width: 100%; padding: 0; }
  .panel { box-shadow: none; }
}
