/* ==========================================================
   Correspondence Portal - shared styles (railway theme)

   Colours: railway navy and signal blue, a cool platform-grey
   background, and signal amber as the single accent.
   Type: Bahnschrift (the DIN-style transport signage face that
   ships with Windows 10 and 11), falling back to Segoe UI.
   Change the colours in :root to restyle the whole site.
   ========================================================== */

:root {
    --bg: #eceff4;
    --surface: #ffffff;
    --border: #d5dbe6;
    --text: #1b2433;
    --muted: #5f6b80;

    --navy: #0b2a5b;
    --accent: #1457a8;
    --accent-dark: #0e4286;
    --accent-soft: #e3ecf9;

    --amber: #e8a317;
    --amber-dark: #7d5200;
    --amber-soft: #fff0c7;

    --success: #0f7a53;
    --success-soft: #dff3e8;
    --danger: #b02e2e;
    --danger-soft: #fae3e3;
    --warning: var(--amber-dark);
    --warning-soft: var(--amber-soft);

    --radius: 3px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Bahnschrift", "DIN Alternate", "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; line-height: 1.25; color: var(--navy); }
h1 { font-size: 26px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Railway track (decorative) ---------- */

.track {
    height: 10px;
    background:
        linear-gradient(rgba(201, 212, 230, 0.9), rgba(201, 212, 230, 0.9)) 0 1px / 100% 2px no-repeat,
        linear-gradient(rgba(201, 212, 230, 0.9), rgba(201, 212, 230, 0.9)) 0 7px / 100% 2px no-repeat,
        repeating-linear-gradient(90deg, rgba(201, 212, 230, 0.4) 0 4px, transparent 4px 18px);
}

/* ---------- Header and navigation ---------- */

.app-header { background: var(--navy); color: #fff; border-bottom: 3px solid var(--amber); }

.app-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    height: 58px;
    display: flex;
    align-items: center;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 17px;
}
.brand:hover { text-decoration: none; }
/* The logo is blue, so it sits on a white disc to stay visible on the navy header */
.brand-mark { flex-shrink: 0; width: 40px; height: 40px; padding: 2px; border-radius: 50%; background: #fff; object-fit: contain; }

.nav-links { display: flex; gap: 4px; }

.nav-links a {
    color: #c9d4e6;
    padding: 8px 14px;
    border-radius: var(--radius);
    font-weight: 500;
}
.nav-links a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; text-decoration: none; }
.nav-links a.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    box-shadow: inset 0 -3px 0 var(--amber);
}

.nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #c9d4e6;
    font-size: 13px;
}
.nav-user .who { text-align: right; line-height: 1.35; }
.nav-user .who strong { display: block; color: #fff; font-weight: 600; font-size: 14px; }

/* ---------- Page layout ---------- */

.container { max-width: 1280px; width: 100%; margin: 0 auto; padding: 28px 24px 56px; flex: 1 0 auto; }

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-subtitle { color: var(--muted); margin: 4px 0 0; }

.section-title { margin: 30px 0 12px; }

/* ---------- Cards ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card + .card { margin-top: 18px; }
.card-body { padding: 18px; }
.card-header {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: #f7f9fc;
    font-weight: 600;
    color: var(--navy);
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid #c3cbd9;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}
.btn:hover { background: #f1f4f9; text-decoration: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #0b6444; }
.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }

.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-block { display: block; width: 100%; }

/* ---------- Forms ---------- */

label { display: block; font-weight: 500; margin-bottom: 4px; }

input[type="text"],
input[type="password"],
input[type="url"],
input[type="email"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #c3cbd9;
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: var(--danger); font-size: 12px; }

.search-bar { display: flex; gap: 8px; align-items: center; }
.search-bar input { width: 340px; max-width: 100%; }

.stack > * + * { margin-top: 12px; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; }

.table th {
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy);
    background: #e6ebf3;
    padding: 10px 14px;
    border-bottom: 2px solid var(--navy);
    white-space: nowrap;
}

.table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table tbody tr:hover { background: #f6f8fc; }
.table tbody tr:last-child td { border-bottom: none; }

.cell-wrap { min-width: 180px; max-width: 300px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

/* ---------- Badges (each has a small signal-light dot) ---------- */

.badge {
    display: inline-block;
    padding: 2px 9px 2px 8px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    background: #e9edf3;
    color: #4a5468;
}

.badge-stage-10::before,
.badge-stage-20::before,
.badge-stage-30::before,
.badge-stage-40::before,
.badge-stage-50::before,
.badge-stage-60::before,
.badge-stage-70::before,
.badge-stage-80::before,
.badge-success::before,
.badge-warning::before,
.badge-danger::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    margin-right: 6px;
}

.badge-vip { background: var(--amber-soft); color: var(--amber-dark); margin-left: 6px; }

.badge-stage-10 { background: #e9edf3; color: #4a5468; }
.badge-stage-20 { background: #e3ecf9; color: #1457a8; }
.badge-stage-30 { background: #fff0c7; color: #7d5200; }
.badge-stage-40 { background: #dcf1f1; color: #0e6b6b; }
.badge-stage-50 { background: #efe8fa; color: #6b3fb3; }
.badge-stage-60 { background: #e1e8fa; color: #2f4aa8; }
.badge-stage-70 { background: #d6deee; color: #0b2a5b; }
.badge-stage-80 { background: #dff3e8; color: #0f7a53; }

.badge-approved { background: var(--success-soft); color: var(--success); margin-left: 6px; }

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Alerts and messages ---------- */

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: #b9e0cb; }
.alert-danger, .alert-error { background: var(--danger-soft); color: var(--danger); border-color: #efc0c0; }
.alert-info { background: var(--accent-soft); color: var(--accent-dark); border-color: #c4d7f2; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: #f0d99a; }

/* ---------- Home page ---------- */

.link-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }

.link-card {
    display: block;
    padding: 22px;
    color: var(--text);
    border-top: 3px solid var(--navy);
}
.link-card:hover { text-decoration: none; border-top-color: var(--amber); background: #fbfcfe; }
.link-card + .link-card { margin-top: 0; }
.link-card h3 { font-size: 17px; margin-bottom: 6px; }
.link-card p { color: var(--muted); margin: 0; }

/* ---------- Dashboard ---------- */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    padding: 14px 18px;
    margin-bottom: 18px;
}
.filter-bar .field { min-width: 210px; }
.filter-bar label { font-size: 13px; color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 5px solid var(--navy);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 30px; font-weight: 600; line-height: 1.15; margin-top: 2px; color: var(--navy); }
.stat-today { border-left-color: var(--amber); }
.stat-soon { border-left-color: var(--accent); }
.stat-overdue { border-left-color: var(--danger); }
.stat-overdue .stat-value { color: var(--danger); }
.stat-disposed { border-left-color: var(--success); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.grid-2 .card + .card { margin-top: 0; }
.chart-box { position: relative; height: 300px; padding: 14px 18px 18px; }

/* ---------- Entry detail ---------- */

.detail-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.detail-layout .card + .card { margin-top: 18px; }

.info-list { display: grid; grid-template-columns: 150px 1fr; margin: 0; }
.info-list dt { color: var(--muted); padding: 9px 12px 9px 0; border-bottom: 1px solid var(--border); }
.info-list dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--border); }
.info-list dt:last-of-type, .info-list dd:last-of-type { border-bottom: none; }

.elapsed { font-size: 28px; font-weight: 600; color: var(--navy); line-height: 1.2; }

.holder { font-size: 17px; font-weight: 600; color: var(--navy); line-height: 1.3; margin-top: 2px; }

/* ---------- Tabs (entry list) ---------- */

.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 2px solid var(--border); }
.tab { padding: 8px 16px; color: var(--muted); font-weight: 500; margin-bottom: -2px; border-bottom: 3px solid transparent; }
.tab:hover { color: var(--navy); text-decoration: none; }
.tab.active { color: var(--navy); border-bottom-color: var(--amber); }
.tab-count { display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--amber-soft); color: var(--amber-dark); font-size: 12px; font-weight: 600; text-align: center; }

/* ---------- Railway-line stage tracker (entry page and dashboard pipeline) ---------- */

.tracker-card { padding: 22px 12px 18px; margin-bottom: 18px; overflow-x: auto; }
.tracker-card + .detail-layout { margin-top: 0; }

.stations { --dot: 18px; list-style: none; margin: 0; padding: 0; display: flex; min-width: 760px; }
.stations.pipeline { --dot: 40px; }

.station { position: relative; flex: 1; text-align: center; padding: 0 4px; }

/* the rail running back to the previous station */
.station + .station::before {
    content: "";
    position: absolute;
    top: calc(var(--dot) / 2 - 2px);
    left: -50%;
    width: 100%;
    height: 4px;
    background: repeating-linear-gradient(90deg, #c3cbd9 0 6px, transparent 6px 10px);
}
.station-done + .station::before,
.station-done + .station-current::before,
.station-current + .station-done::before { background: var(--navy); }

.station .dot {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--dot);
    height: var(--dot);
    border-radius: 50%;
    background: #fff;
    border: 3px solid #c3cbd9;
    color: var(--navy);
    font-weight: 600;
    font-size: 15px;
}
.station-done .dot { background: var(--navy); border-color: var(--navy); }
.station-current .dot { background: var(--amber); border-color: var(--navy); box-shadow: 0 0 0 4px var(--amber-soft); }
.station-final.station-current .dot { background: var(--success); border-color: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }

.st-name, .st-caption, .st-time, .st-overdue { display: block; }
.st-name { margin-top: 8px; font-weight: 600; color: var(--navy); font-size: 13px; line-height: 1.25; }
.station-upcoming .st-name { color: var(--muted); font-weight: 500; }
.st-caption { color: var(--muted); font-size: 12px; min-height: 18px; }
.st-time { color: var(--text); font-size: 12px; font-weight: 500; min-height: 18px; }
.st-overdue { color: var(--danger); font-size: 12px; font-weight: 600; }

.stat-small { font-size: 22px; padding-top: 6px; }
.bar { display: inline-block; vertical-align: middle; width: 110px; height: 8px; margin-right: 8px; background: #e6ebf3; border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }

/* ---------- Bulk entry grid ---------- */

.grid-table th, .grid-table td { padding: 6px 8px; }
.grid-table th { padding-top: 9px; padding-bottom: 9px; }
.grid-table input, .grid-table select, .grid-table textarea { padding: 6px 8px; }
.grid-table .col-slno { min-width: 90px; }
.grid-table .col-type { min-width: 130px; }
.grid-table .col-date { min-width: 150px; }
.grid-table .col-from { min-width: 210px; }
.grid-table .col-subject { min-width: 270px; }
.grid-table .col-comments { min-width: 220px; }
.grid-table .col-due { min-width: 150px; }
.grid-table .col-dept { min-width: 170px; }
.th-action { display: flex; align-items: center; gap: 8px; }
.type-custom { margin-top: 4px; }

.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; }

/* ---------- Login page ---------- */

.login-page { background: var(--navy); }

/* A length of track runs across the whole page, behind the login card */
.login-page::before {
    content: "";
    position: fixed;
    left: 0;
    right: 0;
    top: 50%;
    height: 14px;
    margin-top: -7px;
    background:
        linear-gradient(rgba(143, 163, 196, 0.55), rgba(143, 163, 196, 0.55)) 0 2px / 100% 2px no-repeat,
        linear-gradient(rgba(143, 163, 196, 0.55), rgba(143, 163, 196, 0.55)) 0 10px / 100% 2px no-repeat,
        repeating-linear-gradient(90deg, rgba(143, 163, 196, 0.25) 0 5px, transparent 5px 22px);
}
.login-page .container { position: relative; }

.login-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; padding: 32px; border-top: 4px solid var(--amber); }
.login-logo { width: 52px; height: 52px; object-fit: contain; flex-shrink: 0; }
.login-card .login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.login-card h1 { font-size: 22px; }
.login-card .page-subtitle { margin: 0 0 8px; }
.login-form label { margin-top: 14px; }
.login-form .btn { margin-top: 22px; }

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
    .grid-2, .detail-layout { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
    .app-header-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
    .nav-user { margin-left: 0; width: 100%; justify-content: space-between; }
    .container { padding: 20px 16px 40px; }
}

/* Dashboard pipeline: one continuous rail */
.pipeline .station + .station::before { background: var(--navy); }

/* Live serial number check on the bulk entry page */
.slno-status { font-size: 12px; line-height: 1.25; margin-top: 3px; }
.slno-status.ok { color: var(--success); font-weight: 600; }
.slno-status.bad { color: var(--danger); font-weight: 600; }

/* ---------- Bulk entry grid ---------- */
.grid-tips { padding: 10px 16px; margin-bottom: 14px; }
.grid-tips summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.grid-tips ul { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
.grid-tips li { margin: 3px 0; }
kbd { background: #eef1f6; border: 1px solid var(--border); border-radius: 3px; padding: 0 5px; font: 12px Consolas, monospace; color: var(--text); }

.grid-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.grid-bar .spacer { flex: 1; }
.grid-msg { min-height: 22px; margin-bottom: 8px; color: var(--muted); }
.grid-msg.err { color: var(--danger); font-weight: 600; }
.grid-errlist { margin: 0 0 10px; padding: 8px 14px 8px 32px; background: var(--danger-soft); border: 1px solid var(--danger); border-radius: var(--radius); color: var(--danger); font-size: 13px; }
.grid-errlist a { color: var(--danger); font-weight: 600; }

.grid-wrap { overflow: auto; max-height: 68vh; outline: none; }
table.grid { border-collapse: collapse; table-layout: fixed; width: 100%; }
table.grid th, table.grid td { border: 1px solid var(--border); height: 32px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.grid thead th { position: sticky; top: 0; z-index: 4; background: #eef1f6; text-align: left; color: var(--navy); font-weight: 600; }
table.grid th.rn { position: sticky; left: 0; z-index: 3; width: 44px; min-width: 44px; padding: 0; text-align: center; background: #eef1f6; color: var(--muted); font-weight: 400; cursor: pointer; }
table.grid thead th.rn { z-index: 5; cursor: default; }
table.grid td { position: relative; background: var(--surface); cursor: cell; user-select: none; }
table.grid td.s { background: var(--accent-soft); }
table.grid td.a { background: var(--surface); outline: 2px solid var(--accent); outline-offset: -2px; }
table.grid td.e { background: var(--danger-soft); box-shadow: inset 0 0 0 1px var(--danger); }
table.grid td.fp { background: var(--amber-soft); }
table.grid .fh { position: absolute; right: 0; bottom: 0; width: 9px; height: 9px; background: var(--accent); border: 1px solid var(--surface); cursor: crosshair; z-index: 2; }
table.grid td input { position: absolute; inset: 0; width: 100%; height: 100%; border: 2px solid var(--accent); padding: 0 6px; font: inherit; background: var(--surface); color: var(--text); outline: none; z-index: 3; }

/* Snapshot of the original email / letter (entry page) */
.snapshot + .snapshot { margin-top: 18px; }
.snapshot-img { display: block; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.snapshot-pdf { display: block; width: 100%; height: 520px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.snapshot-meta { margin-top: 6px; font-size: 12px; color: var(--muted); }
.snapshot-add { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

/* Snapshot column in the bulk entry grid */
table.grid td.snapcell { font-size: 12px; }
table.grid .snap-open { color: var(--accent); font-weight: 600; cursor: pointer; }
table.grid .snap-wrap { display: flex; align-items: center; gap: 6px; height: 100%; }
table.grid .snap-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
table.grid .snap-view { flex: none; font-weight: 600; }

/* Bulk entry uses more of the screen width than other pages */
.wide-page .container, .wide-page .app-header-inner { max-width: 1760px; }
.wide-page .container { padding-left: 12px; padding-right: 12px; }
.wide-page .app-header-inner { padding-left: 12px; padding-right: 12px; }

/* Entries list: squeezed so every column fits without a sideways scrollbar.
   Text columns wrap sooner, long stage names wrap inside their badge, and a VIP badge
   drops under the reference number when space is tight. */
.table-fit th, .table-fit td { padding-left: 10px; padding-right: 10px; }
.table-fit .cell-wrap { min-width: 100px; max-width: 280px; }
/* Reference no stacks as Division/ Year/ Number: the column shrinks to its narrowest width, so the
   line breaks after each slash (see the ref_breaks filter) always happen */
.table-fit td.ref { width: 1%; }
.table-fit td.ref .rp { white-space: nowrap; }
.table-fit td .badge { white-space: normal; line-height: 1.35; margin: 1px 0; }
.table-fit td.stage .badge { display: inline-flex; align-items: flex-start; max-width: 150px; }
.table-fit td.stage .badge::before { flex: none; margin-top: 0.4em; }

/* ---------- Administration ---------- */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; max-width: 780px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-field input[type="text"], .form-field input[type="password"], .form-field input[type="url"], .form-field input[type="email"], .form-field select { width: 100%; }
.form-field.has-error input, .form-field.has-error select { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 13px; margin-top: 4px; }
.static-value { padding: 8px 0; font-weight: 600; }
.check-label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check-label input { width: auto; }
.narrow-card { max-width: 520px; }
.password-help ul { margin: 6px 0 0; padding-left: 18px; }
.hint-list { color: var(--muted); margin: 16px 0 0; padding-left: 20px; }
.hint-list li { margin: 4px 0; }

.credentials .pw-box { font: 600 20px Consolas, "Courier New", monospace; letter-spacing: 1px; padding: 10px 14px; background: #f3f6fb; border: 1px dashed var(--border); border-radius: var(--radius); display: inline-block; user-select: all; }
.credentials .pw-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.credentials .form-field { margin-bottom: 14px; }

td.actions { white-space: nowrap; }
td.actions form { display: inline-block; margin: 0 2px 0 0; }
.filter-actions { display: flex; gap: 8px; align-items: flex-end; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 14px 0; }

.division-card .division-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.division-card .head-action { margin-left: auto; }
.inline-form { display: flex; align-items: center; gap: 8px; margin: 0; }
.inline-form input[type="text"] { width: 260px; max-width: 100%; }
.sub-table { margin-bottom: 14px; }
.add-sub { margin-top: 6px; }

/* Dashboard: click-to-filter (nothing changes until something is clicked) */
[data-filter-flag], [data-filter-dept], [data-filter-stage], [data-filter-clear] { cursor: pointer; }
.filter-note { margin: -6px 0 10px; color: var(--muted); font-size: 14px; }
.filter-note a { font-weight: 600; }

/* ---------- Notifications, comments and profile ---------- */
.bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin-right: 10px; color: #dbe4f5; border-radius: 6px; }
.bell:hover { color: #fff; background: rgba(255, 255, 255, 0.12); text-decoration: none; }
.bell-count { position: absolute; top: 1px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--navy); }
.bell-count[hidden] { display: none; }

.notice-list { list-style: none; margin: 0; padding: 0; }
.notice a { display: grid; grid-template-columns: 90px 1fr auto; gap: 14px; align-items: start; padding: 14px 18px; border-bottom: 1px solid var(--border); color: var(--text); }
.notice a:hover { background: #f7f9fc; text-decoration: none; }
.notice:last-child a { border-bottom: none; }
.notice.unread a { background: #f3f8ff; box-shadow: inset 3px 0 0 var(--accent); }
.notice.unread strong { color: var(--navy); }
.notice:not(.unread) strong { font-weight: 500; }
.notice-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.notice-body { color: var(--muted); font-size: 14px; }
.notice-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.notice-kind { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; text-align: center; background: #e9edf3; color: #4a5468; }
.notice-kind.kind-remark { background: #e3ecf9; color: #1457a8; }
.notice-kind.kind-comment { background: #fff0c7; color: #7d5200; }
.notice-kind.kind-message { background: #dff3e8; color: #0f7a53; }
.notice-kind.kind-reset_request { background: #fae3e3; color: #b02e2e; }
.notice-list .empty { padding: 28px; text-align: center; color: var(--muted); }
.message-body { font-size: 16px; line-height: 1.6; max-width: 760px; }
.reset-flag { color: var(--danger); font-weight: 600; }

.comment + .comment { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.comment-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.comment-text { line-height: 1.55; }
.comment-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.comment-form textarea { width: 100%; margin-top: 6px; }
.comment-form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; flex-wrap: wrap; }

/* A notification (or link) that points at a remark or comment highlights it on arrival */
.comment, tr[id^="history-"], #comments { scroll-margin-top: 20px; }
.comment:target { background: var(--amber-soft); outline: 2px solid var(--amber); outline-offset: 6px; border-radius: 4px; }
tr[id^="history-"]:target td { background: var(--amber-soft); }

.detail-list { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; margin: 0 0 12px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-weight: 500; }
.login-help { text-align: center; margin: 14px 0 0; }
.form-section { margin: 4px 0 12px; font-size: 15px; color: var(--navy); }
.form-section:not(:first-of-type) { margin-top: 26px; }
.form-field textarea { width: 100%; }

/* ---------- Footer credits ---------- */
.app-footer { flex-shrink: 0; padding: 14px 24px 18px; border-top: 1px solid var(--border); text-align: center; color: var(--muted); font-size: 13px; }
.app-footer .sep { margin: 0 12px; color: #b8c1d1; }
.app-footer a { color: var(--accent); font-weight: 500; }
.app-footer strong { color: var(--text); font-weight: 600; }
.contact-card .detail-list { max-width: 640px; }
.contact-card .detail-list dd .hint { font-weight: 400; margin-top: 2px; }
@media print { .app-footer { display: none; } }

/* ---------- Settings (gear) menu in the header ---------- */
.settings { position: relative; }
.settings-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; background: transparent; border: 0; border-radius: 6px; color: #dbe4f5; cursor: pointer; }
.settings-btn:hover, .settings-btn[aria-expanded="true"] { color: #fff; background: rgba(255, 255, 255, 0.14); }
.settings-btn:focus-visible, .bell:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.settings-menu { position: absolute; right: 0; top: calc(100% + 10px); z-index: 100; min-width: 200px; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 28px rgba(11, 42, 91, 0.22); }
.settings-menu::before { content: ""; position: absolute; top: -6px; right: 13px; width: 10px; height: 10px; background: #fff; border-left: 1px solid var(--border); border-top: 1px solid var(--border); transform: rotate(45deg); }
.settings-menu form { margin: 0; }
.menu-item { display: block; width: 100%; padding: 9px 12px; background: transparent; border: 0; border-radius: 6px; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.menu-item:hover, .menu-item:focus { background: #eef3fb; color: var(--navy); text-decoration: none; outline: none; }
.settings-menu form + .menu-item, .settings-menu .menu-item + form { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

/* The login pages have a dark blue background, so the footer credits turn light there */
.login-page .app-footer { position: relative; color: #b9c7e2; border-top-color: rgba(255, 255, 255, 0.16); }
.login-page .app-footer strong { color: #fff; }
.login-page .app-footer a { color: #ffd37a; }
.login-page .app-footer .sep { color: rgba(255, 255, 255, 0.35); }

.notice-kind.kind-lockout { background: #fae3e3; color: #b02e2e; }
.session-ended { padding: 10px 24px; background: var(--amber-soft); color: var(--amber-dark); border-bottom: 2px solid var(--amber); text-align: center; font-weight: 500; }

/* ---------- Entries list: filters, sortable headers, export ---------- */

.export-links { display: flex; gap: 8px; align-items: center; }

.list-filters { padding: 14px 18px; margin-bottom: 16px; }
.list-filters-main { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.list-filters-main input[type="text"] { flex: 1 1 auto; }
.list-filters-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 14px; align-items: end; }
.list-filters-grid label { font-size: 13px; color: var(--muted); }
.list-filters-check label { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; margin: 0 0 8px; }
.list-filters-check input { width: auto; }

.sort-link { color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--accent); text-decoration: underline; }
.table th.sorted { background: #d9e2f0; }
.sort-arrow { font-size: 10px; color: var(--accent); }

/* ---------- Corrections and reopening ---------- */

.detail-edit { margin: 14px 0 0; }
.correction { padding: 10px 0; border-bottom: 1px solid var(--border); }
.correction:last-child { border-bottom: 0; }
.correction-reason { margin: 4px 0; font-weight: 500; }
.correction-list { margin: 4px 0 0; padding-left: 20px; color: var(--muted); }
.correction-list li { margin: 2px 0; }

/* ---------- Department batch bar on Bulk Entry, "Assigned to" line ---------- */

.batch-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 18px; padding: 14px 18px; margin-bottom: 14px; }
.batch-bar .field { display: flex; flex-direction: column; gap: 4px; min-width: 220px; }
.batch-bar .field label { font-size: 13px; color: var(--muted); }
.batch-bar select, .batch-bar input[type="text"] { min-width: 240px; }
.batch-bar .batch-hint { flex: 1 1 260px; margin: 0; }
.batch-bar .batch-empty { flex: 1 1 100%; margin: 0; }
.deptnote { font-weight: 600; color: var(--text); }
.deptnote.warn { color: var(--danger); }
.assigned-line { font-size: 12px; color: var(--muted); font-style: italic; }

.notice-kind.kind-reminder { background: #ffe4cc; color: #a34a00; }

/* ---------- Excel upload ---------- */

.upload-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 18px; margin-bottom: 14px; }
.upload-bar .upload-hint { flex: 1 1 100%; margin: 0; }
.upload-summary .card-body { display: flex; gap: 28px; flex-wrap: wrap; }
.upload-count { font-size: 15px; color: var(--muted); }
.upload-count strong { font-size: 26px; color: var(--text); margin-right: 4px; }
.upload-count.ok strong { color: #1a7f37; }
.upload-count.bad strong { color: var(--danger); }
.upload-problems { margin: 0; padding-left: 18px; }
