:root {
  color-scheme: light;
  --ink: #102342;
  --muted: #4c6382;
  --line: #d8e5f4;
  --bg: #eef5ff;
  --blue: #0751bf;
  --shadow: 0 12px 34px #203d7210;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 3vw, 2.4rem); line-height: 1.1; letter-spacing: -.045em; }
h2 { font-size: 1.23rem; letter-spacing: -.025em; }
h3 { font-size: 1.05rem; }
small { color: var(--muted); font-size: .8rem; }
button, select, input, textarea { font: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 3px solid #558bff; outline-offset: 3px; }

.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side {
  display: flex;
  flex-direction: column;
  gap: 36px;
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 29px 16px 20px;
  background: radial-gradient(ellipse at top left, #0b4387, transparent 56%), #071a37;
  color: #c7d5f1;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 11px; }
.brand strong { color: #fff; font-size: 1.24rem; letter-spacing: .035em; white-space: nowrap; }
.brand-logo { display: block; width: 49px; height: auto; flex: 0 0 49px; }
.side p { padding: 0 11px; margin-top: 13px; font-size: .75rem; }
.nav { display: grid; gap: 7px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #d6e0f7;
  font-size: .89rem;
  font-weight: 600;
  text-decoration: none;
}
.nav a::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border: 1px solid #8aa4d6;
  border-radius: 50%;
}
.nav a:hover { background: #233555; color: #fff; }
.nav a[aria-current] { background: #103b71; border-color: #367ab3; color: #fff; }
.nav a[aria-current]::before {
  background: #62f5a0;
  border-color: #62f5a0;
  box-shadow: 0 0 8px #62f5a080;
  animation: nav-indicator-pulse 2.8s ease-in-out infinite;
}
@keyframes nav-indicator-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}
@media (prefers-reduced-motion: reduce) {
  .nav a[aria-current]::before { animation: none; }
}
.side::after {
  content: "";
  order: 1;
  flex: 1 1 0;
  min-height: 0;
  margin: -36px -16px;
  background: linear-gradient(145deg, #0c3972b8, #071a3759 60%, #071a37ba),
    url("/assets/tvri-tower.jpg") center 38% / cover no-repeat;
  mask-image: linear-gradient(to bottom, transparent, #000 32%, #000 83%, transparent);
  opacity: .65;
  pointer-events: none;
}
.side-footer { order: 2; display: grid; gap: 11px; padding-top: 11px; border-top: 1px solid #344362; font-size: .74rem; }
.side-footer > span { padding-inline: 11px; }
.side-account { padding: 9px 11px; border: 1px solid #49668b; border-radius: 9px; color: #e8f1ff; font-size: .84rem; font-weight: 600; text-decoration: none; }
.side-account:hover, .side-account[aria-current] { color: #fff; background: #103b71; border-color: #367ab3; }
.account-settings { max-width: 620px; }
.account-details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .3em 1em; margin-block: .5em 0; }
.account-details dd { margin: 0; overflow-wrap: anywhere; }

.top {
  min-height: 68px;
  padding: 10px clamp(16px, 3vw, 36px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.route { font-size: .9rem; font-weight: 700; color: var(--muted); }
.top-tools, .identity { display: flex; align-items: center; gap: 9px; }
.top-tools { flex-wrap: wrap; }
.top form { margin: 0; }
.identity { color: #263955; font-size: .83rem; }
.identity strong { overflow-wrap: anywhere; }
.avatar { padding: 5px; min-width: 30px; text-align: center; border-radius: 10px; color: #344f9c; background: #e9efff; font-weight: 750; }
.demo, .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .73rem;
  font-weight: 750;
  white-space: nowrap;
}
.demo { background: #e8eeff; color: #29489b; }
.demo::before, .badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

main { width: 100%; max-width: 1570px; margin: auto; padding: 27px clamp(16px, 3vw, 36px) 45px; }
.page-head, .section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.page-head { margin-bottom: 24px; }
.page-head p { color: var(--muted); margin-top: 8px; }
.section-head { align-items: baseline; margin-bottom: 11px; }
.dashboard-hero {
  padding: clamp(20px, 3.4vw, 38px);
  margin-bottom: 19px;
  border: 1px solid #2873c9;
  border-radius: 21px;
  background: linear-gradient(90deg, #061b41f2, #072c65ad 52%, #072c6514),
    #103e84 url("/assets/tvri-blue.webp") center 58% / cover no-repeat;
  box-shadow: 0 13px 34px #153e8033;
  color: #fff;
}
.dashboard-hero .page-head p, .dashboard-hero .control { color: #deebff; }
.dashboard-hero .filters { margin: 0; }
.dashboard-hero select { background: #172e5a; color: #fff; border-color: #7d9ace; }
.dashboard-hero select option { background: #172e5a; color: #fff; }
.dashboard-hero .btn { border-color: #b4d7ff; background: #d7ebff; color: #16345d; }
.dashboard-hero .btn:hover { background: #fff; }
.dashboard-clock {
  color: #e0eeff;
  text-align: right;
}
.clock-date { display: block; font-size: .85rem; }
.dashboard-clock time { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 750; color: #fff; font-variant-numeric: tabular-nums; }
.dashboard-clock time + span { font-size: .75rem; font-weight: 700; }
.status-chart { margin-bottom: 24px; }
.status-chart ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.status-bar { display: grid; grid-template-columns: minmax(0, 170px) minmax(32px, 1fr) minmax(2ch, auto); align-items: center; gap: 12px; }
.status-bar strong { text-align: right; font-variant-numeric: tabular-nums; }
.status-track { height: 10px; border-radius: 5px; background: #eaf0f8; overflow: hidden; }
.status-track > span { display: block; height: 100%; border-radius: inherit; background: var(--tone); }

.actions, .filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters { margin-bottom: 20px; }
.control { display: grid; gap: 5px; font-size: .79rem; font-weight: 700; color: var(--muted); }
.control select { min-width: 152px; }
select, .control input, input[type=number], textarea {
  border: 1px solid #bccbe1;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 8px 11px;
}
textarea { width: 100%; min-height: 100px; resize: vertical; }
input[type=number] { width: 92px; }
.btn {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid #bccbe1;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: .87rem;
  font-weight: 700;
  text-decoration: none;
}
.btn:hover { background: #edf3ff; }
.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.primary:hover { background: #1b3caa; }
.link { color: #2149b6; font-weight: 700; text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 26px; }
.card {
  position: relative;
  overflow: hidden;
  min-height: 120px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--tone);
  border-radius: 15px;
  box-shadow: var(--shadow);
  background: linear-gradient(145deg, var(--fill), #fff 54%);
  color: var(--ink);
  text-decoration: none;
}
.card .label { display: flex; align-items: baseline; gap: 7px; font-weight: 750; font-size: .85rem; }
.card .label::before { content: ""; width: 7px; height: 7px; flex: 0 0 7px; background: var(--tone); border-radius: 50%; }
.card strong { display: block; margin: 6px 0 0; font-size: 2.35rem; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.05em; }
.card small { display: block; margin-top: 5px; }
a.card:hover, .card[aria-current] { border-color: var(--tone); box-shadow: 0 0 0 1px var(--tone), var(--shadow); }
.blue { --tone: #254fb7; --fill: #e8efff; }
.amber { --tone: #844800; --fill: #fff1d9; }
.red { --tone: #a12a45; --fill: #fdecf1; }
.green { --tone: #11634d; --fill: #e2f6ed; }
.gray { --tone: #445872; --fill: #edf1f7; }
.badge { background: var(--fill); color: var(--tone); }
.late { display: block; margin-top: 4px; color: #a12a45; font-size: .72rem; font-weight: 650; }

.table-wrap, .panel {
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: var(--shadow);
  background: #fff;
}
.table-wrap { max-width: 100%; overflow: auto; }
table { width: 100%; min-width: 560px; border-collapse: collapse; text-align: left; }
th, td { padding: 12px clamp(12px, 1.5vw, 20px); }
th { background: #e9f0fc; color: #334c73; font-size: .76rem; white-space: nowrap; }
td { border-bottom: 1px solid #e9eff7; font-size: .85rem; }
tbody tr:nth-child(even) { background: #f8faff; }
tbody tr:hover, tbody tr:focus-within { background: #eef5ff; }
tr:last-child td { border-bottom: 0; }
.panel { min-width: 0; padding: 18px; }
.panel > h2 { margin-bottom: 10px; }
.panel p + p { margin-top: 6px; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.note { background: #fff8ed; border-color: #f0dcb8; }
.note p { white-space: pre-wrap; overflow-wrap: anywhere; }
.history { margin: 7px 0 0; padding-left: 19px; }
.history li + li { margin-top: 7px; }
.footer-actions { display: flex; justify-content: flex-end; gap: 9px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 22px; }
.help { margin-top: 12px; color: var(--muted); font-size: .8rem; }
.empty { min-height: 88px; display: grid; align-content: center; gap: 4px; }
.bars { display: grid; gap: 15px; margin-top: 14px; }
.bar { display: grid; grid-template-columns: 80px 1fr 40px; align-items: center; gap: 10px; font-size: .8rem; }
.track { background: #e8eef7; border-radius: 8px; height: 12px; overflow: hidden; }
.track span { background: #2c5fc8; display: block; height: 100%; border-radius: 8px; }
.unit-list { list-style: none; margin: 10px 0 0; padding: 0; }
.unit-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.notice:not(:empty) { padding: 9px 12px; border: 1px solid #bbdccc; border-radius: 9px; background: #eaf7f0; color: #12533e; }
.notice.error { border-color: #efc9c9; background: #fff0f0; color: #8e2424; }
.file-edit { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.file-edit input { max-width: 210px; }
.file-edit span { overflow-wrap: anywhere; }
.stack { display: grid; gap: 14px; }
.report-content { margin-top: 14px; }
.review-form { margin-top: 18px; max-width: 650px; }
.review-form > button { justify-self: start; }

.shell.guest { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100dvh; }
.guest > .side { display: none; }
.guest > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: linear-gradient(115deg, #061b41ed, #07327075),
    #103e84 url("/assets/tvri-blue.webp") center / cover no-repeat;
}
.guest main { max-width: 850px; padding: clamp(24px, 4vw, 48px) clamp(16px, 3vw, 36px); }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 18px; color: #fff; }
.login-brand p { font-size: clamp(.85rem, 2.5vw, 1.1rem); font-weight: 650; }
.login-logo { display: block; flex: none; width: clamp(76px, 9vw, 104px); height: auto; }
.guest .page-head { justify-content: center; text-align: center; color: #fff; }
.guest .page-head p, .guest .help { color: #e0eeff; }
.guest .help .link { color: #e0eeff; }
.login-layout { display: flex; justify-content: center; align-items: flex-start; gap: 15px; flex-wrap: wrap; }
.login-layout .panel { width: min(100%, 380px); padding: clamp(16px, 3vw, 25px); }
.login-layout .primary { width: 100%; justify-content: center; }
.login-layout dd { margin: 0 0 8px; }
.login-layout dt { font-weight: 700; }

.mail-meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .2em 1em; margin: 1.5em 0 1em; }
.mail-meta dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-content { white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-print {
  width: min(100%, 210mm);
  min-height: 250mm;
  padding: clamp(18px, 4vw, 20mm);
  margin: 0 auto;
  background: #fff;
  color: #111;
  font: 11pt/1.45 Arial, sans-serif;
  page: mail-draft;
}
.mail-print > img { display: block; width: 31mm; height: auto; filter: brightness(0) saturate(100%) invert(17%) sepia(29%) saturate(2100%) hue-rotate(190deg); }
.mail-print h2, .mail-print-number, .mail-print-status { text-align: center; }
.mail-print h2 { font-size: 12pt; margin: .15em 0; }
.mail-print-status { color: #7d2525; font-size: 9pt; font-weight: bold; }
.mail-print .mail-meta { padding-bottom: .4em; border-bottom: 1px solid currentColor; }
.mail-signature { margin: 2em 0 1.6em auto; width: min(100%, 69mm); break-inside: avoid; }
.mail-signature-space { height: 18mm; }
.mail-print footer { margin-top: 2em; font-size: 8pt; color: #142f57; break-inside: avoid; }
.mail-templates, .mail-workspace { display: grid; gap: 18px; }
.mail-templates { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mail-workspace { grid-template-columns: minmax(0, 4fr) minmax(0, 5fr); align-items: start; }
.mail-workspace > section { min-width: 0; }
.mail-workspace .mail-print { aspect-ratio: 210 / 297; min-height: 0; padding: clamp(18px, 3vw, 42px); box-shadow: var(--shadow); }
.mail-print.leave-print, .mail-workspace .leave-print {
  position: relative;
  container-type: inline-size;
  min-height: 0;
  aspect-ratio: 210 / 297;
  padding: 0;
  page: leave-form;
}
.leave-print > img.leave-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; filter: none; }
.leave-value, .leave-draft-label { position: absolute; font: var(--leave-font, 1.2cqw)/1.15 "Times New Roman", serif; }
.leave-value { white-space: nowrap; }
.leave-value.leave-replace:not(:empty) { background: #fff; }
.leave-value.leave-check, .leave-value.leave-option { text-align: center; }
.leave-value.leave-check { font-family: Arial, sans-serif; }
.leave-value.leave-address { white-space: normal; overflow-wrap: anywhere; font-size: 1.65cqw; }
.leave-draft-label { top: 3.55%; left: 7.1%; color: #7d2525; font-weight: bold; }
.mail-workspace fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 12px; }
.mail-workspace details > .stack { margin-top: 12px; }
.assignment-print .mail-print-number { margin: 0; }
.assignment-print h3 { text-align: center; margin: 1.4em 0 0; font-size: 11pt; }
.assignment-clauses { display: grid; grid-template-columns: minmax(5.7em, 22%) minmax(0, 1fr); gap: .6em 1em; margin: 1.4em 0; }
.assignment-clauses dt::after { content: " :"; }
.assignment-clauses dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.assignment-clauses ol { margin: 0; padding-left: 1.25em; }
.assignment-clauses li + li { margin-top: .25em; }
.assignment-attachment { margin-top: 18px; }
.assignment-attachment[hidden], [data-assignment-input-table][hidden] { display: none; }
.assignment-attachment header { margin-left: 50%; margin-bottom: 2.5em; overflow-wrap: anywhere; }
.assignment-names { width: 100%; min-width: 0; border-collapse: collapse; table-layout: fixed; }
.assignment-names th, .assignment-names td { border: 1px solid currentColor; padding: .25em .5em; color: inherit; background: transparent; font-size: inherit; overflow-wrap: anywhere; }
.assignment-names th:first-child, .assignment-names td:first-child { width: 3.4em; text-align: center; }
.assignment-print .assignment-names tr { break-inside: avoid; background: transparent; }
[data-assignment-editor] .table-wrap { overflow-x: auto; }
[data-assignment-input-table] { min-width: 360px; }
[data-assignment-input-table] input { width: 100%; min-width: 6.5em; }

@page mail-draft { size: A4; margin: 20mm; }
@page leave-form { size: A4; margin: 0; }
@media print {
  body:has(.mail-print) { background: #fff; }
  .shell:has(.mail-print) { display: block; min-height: 0; }
  .shell:has(.mail-print) .side, .shell:has(.mail-print) .top,
  main:has(.mail-print) > .page-head, .mail-workspace > .panel, .leave-form-screen-only { display: none; }
  .mail-workspace { display: block; }
  main:has(.mail-print), .mail-print { width: 100%; max-width: none; min-height: 0; margin: 0; padding: 0; }
  .mail-workspace .mail-print { aspect-ratio: auto; padding: 0; box-shadow: none; }
  .mail-print.leave-print, .mail-workspace .leave-print { width: 210mm; height: 297mm; aspect-ratio: auto; box-shadow: none; }
  .assignment-attachment { break-before: page; }
  .assignment-names thead { display: table-header-group; }
}

@media (max-width: 1050px) {
  .shell { grid-template-columns: 192px minmax(0, 1fr); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mail-templates, .mail-workspace { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .shell { display: block; }
  .side { position: static; height: auto; padding: 12px; gap: 10px; }
  .brand { padding: 0; }
  .brand-logo { width: 42px; flex-basis: 42px; }
  .side p, .side-footer > span { display: none; }
  .side-footer { justify-items: start; padding-top: 8px; }
  .side::after { content: none; }
  .nav { display: flex; overflow: auto; gap: 5px; padding: 4px; margin: -4px; }
  .nav a { padding: 7px 9px; white-space: nowrap; font-size: .8rem; }
  .nav a::before { display: none; }
  .top { min-height: 56px; padding: 8px 12px; }
  .top .btn { min-height: 34px; padding: 5px 8px; }
  .avatar { display: none; }
  main { padding: 18px 12px 27px; }
  .dashboard-hero { border-radius: 16px; }
  .dashboard-hero { background-position: center, 65% center; }
  .dashboard-clock { text-align: left; }
  .status-bar { grid-template-columns: minmax(0, 1fr) minmax(32px, 1fr) minmax(2ch, auto); gap: 8px; font-size: .85rem; }
  .cards { gap: 9px; }
  .card { padding: 11px; }
  .card strong { font-size: 1.9rem; }
  .split { grid-template-columns: 1fr; }
}
