:root {
    --brand: #0b3d91;
    --brand-600: #0a3480;
    --brand-50: #eef3fc;
    --ink: #1d2433;
    --muted: #667085;
    --line: #e4e7ec;
    --surface: #ffffff;
    --canvas: #f4f6fa;
    --ok: #12805c;
    --ok-50: #e7f6ef;
    --warn: #b54708;
    --warn-50: #fff4e5;
    --idle: #475467;
    --idle-50: #f2f4f7;
    --radius: 12px;
    --bs-primary: var(--brand);
    --bs-primary-rgb: 11, 61, 145;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 11, 61, 145;
    --bs-body-font-family: "Inter", "Noto Sans Sinhala", "Noto Sans Tamil", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: var(--ink);
    --bs-border-color: var(--line);
}

body {
    background: var(--canvas);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: .935rem;
}
body.is-embedded { background: var(--surface); }
.app-main { flex: 1 0 auto; }
:lang(si), [lang="si"] { font-family: "Noto Sans Sinhala", var(--bs-body-font-family); }
:lang(ta), [lang="ta"] { font-family: "Noto Sans Tamil", var(--bs-body-font-family); }

.skip-link { position: absolute; top: 8px; left: 8px; z-index: 2000; background: #fff; padding: 8px 12px; border-radius: 8px; }

/* Buttons */
.btn { border-radius: 9px; font-weight: 500; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600); --bs-btn-active-bg: var(--brand-600); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: #c4d3ee; --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.form-control, .form-select { border-radius: 9px; border-color: #d0d5dd; }
.form-control:focus, .form-select:focus { border-color: #7f9ed6; box-shadow: 0 0 0 .2rem rgba(11, 61, 145, .12); }
.form-control[readonly] { background: var(--idle-50); color: var(--muted); }
.form-label { font-weight: 500; font-size: .875rem; margin-bottom: .35rem; }
.req { color: #d92d20; }

/* Navbar */
.app-navbar { background: linear-gradient(90deg, #08306f, var(--brand)); padding: .6rem 0; box-shadow: 0 1px 0 rgba(0,0,0,.08); }
.app-navbar .brand-mark { background: rgba(255,255,255,.12); border-radius: 8px; padding: 3px; object-fit: contain; }
.app-navbar .brand-title { font-weight: 700; font-size: 1rem; color: #fff; }
.app-navbar .brand-sub { font-size: .72rem; color: rgba(255,255,255,.7); }
.app-navbar .nav-link { color: rgba(255,255,255,.8); border-radius: 8px; padding: .45rem .8rem !important; font-weight: 500; }
.app-navbar .nav-link:hover, .app-navbar .nav-link.active { color: #fff; background: rgba(255,255,255,.12); }
.user-chip { display: flex; align-items: center; gap: .6rem; color: #fff; border: 1px solid rgba(255,255,255,.18); padding: .3rem .7rem .3rem .3rem; font-size: .85rem; }
.user-chip:hover, .user-chip:focus, .user-chip.show { color: #fff; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.3); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #fff; color: var(--brand); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

/* Page */
.page-head { padding: 1.75rem 0 1.25rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-head .lead-sm { color: var(--muted); margin: .2rem 0 0; }
.crumbs { font-size: .8rem; color: var(--muted); margin-bottom: .4rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.panel-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }
.panel-head h2 { font-size: 1rem; font-weight: 600; margin: 0; }
.panel-body { padding: 1.25rem; }

/* Stats */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; gap: .9rem; align-items: center; height: 100%; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.stat:hover { border-color: #c4d3ee; box-shadow: 0 4px 14px rgba(16,24,40,.06); color: inherit; }
.stat.active { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--muted); }
.tone-brand { background: var(--brand-50); color: var(--brand); }
.tone-ok { background: var(--ok-50); color: var(--ok); }
.tone-warn { background: var(--warn-50); color: var(--warn); }
.tone-idle { background: var(--idle-50); color: var(--idle); }

/* Status badges */
.status-badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 600; padding: .22rem .6rem; border-radius: 999px; white-space: nowrap; }
.status-published { background: var(--ok-50); color: var(--ok); }
.status-draft { background: var(--idle-50); color: var(--idle); }
.status-disabled { background: var(--warn-50); color: var(--warn); }

/* Table */
.notice-table { margin: 0; }
.notice-table thead th { background: #f9fafb; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 600; border-bottom: 1px solid var(--line); padding: .75rem 1rem; white-space: nowrap; }
.notice-table td { padding: .85rem 1rem; border-color: var(--line); vertical-align: middle; }
.notice-table tbody tr:hover { background: #fafbfd; }
.notice-title { font-weight: 600; color: var(--ink); line-height: 1.35; }
.notice-alt { font-size: .82rem; color: var(--muted); line-height: 1.35; margin-top: .15rem; }
.lang-tag { display: inline-block; font-size: .68rem; font-weight: 600; background: var(--brand-50); color: var(--brand); border-radius: 5px; padding: .05rem .35rem; vertical-align: middle; }
.date-cell { white-space: nowrap; font-size: .86rem; }
.date-cell small { display: block; color: var(--muted); font-size: .72rem; }
.office-cell { font-size: .86rem; color: var(--muted); }
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell form { display: inline; }
.search-box { position: relative; min-width: 240px; }
.search-box .bi { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box .form-control { padding-left: 2.2rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state .bi { font-size: 2.5rem; color: #c4cad4; display: block; margin-bottom: .5rem; }

@media (max-width: 767.98px) {
    .notice-table thead { display: none; }
    .notice-table tr { display: block; border-bottom: 1px solid var(--line); padding: .75rem 1rem; }
    .notice-table td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .25rem 0; }
    .notice-table td[data-label]::before { content: attr(data-label); font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
    .notice-table td.title-cell { display: block; padding-bottom: .5rem; }
    .actions-cell { text-align: left; }
}

/* Forms */
.form-section { padding: 1.25rem 0; border-bottom: 1px dashed var(--line); }
.form-section:first-of-type { padding-top: .25rem; }
.form-section-title { font-weight: 600; margin-bottom: 1rem; display: flex; align-items: center; gap: .55rem; }
.form-section-title .step { width: 24px; height: 24px; border-radius: 50%; background: var(--brand-50); color: var(--brand); font-size: .78rem; display: inline-flex; align-items: center; justify-content: center; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; padding-top: 1.25rem; }
.upload-tile { border: 1px solid var(--line); border-radius: 10px; padding: .9rem; height: 100%; background: #fcfcfd; }
.upload-tile-head { display: flex; gap: .6rem; align-items: center; margin-bottom: .7rem; }
.upload-tile-head .bi { font-size: 1.4rem; color: var(--brand); }
.current-files { margin-bottom: .6rem; }
.current-file { display: flex; align-items: center; gap: .35rem; font-size: .8rem; text-decoration: none; background: var(--brand-50); border-radius: 6px; padding: .3rem .5rem; margin-bottom: .3rem; }
.current-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.is-invalid ~ .invalid-feedback, .was-validated :invalid ~ .invalid-feedback { display: block; }

/* Detail page */
.meta-list { list-style: none; padding: 0; margin: 0; }
.meta-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .65rem 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.meta-list li:last-child { border-bottom: 0; }
.meta-list .k { color: var(--muted); }
.meta-list .v { font-weight: 500; text-align: right; }
.title-block { padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 10px; margin-bottom: .6rem; }
.title-block .lang-tag { margin-bottom: .35rem; }
.title-block .t { font-weight: 600; font-size: 1.02rem; }
.doc-group-title { font-size: .78rem; font-weight: 600; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; margin: 1rem 0 .5rem; }
.doc-group-title:first-child { margin-top: 0; }
.doc-item { display: flex; align-items: center; gap: .8rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; margin-bottom: .5rem; }
.doc-item .doc-ico { width: 38px; height: 38px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--brand-50); color: var(--brand); font-size: 1.15rem; flex-shrink: 0; }
.doc-item .doc-name { font-weight: 500; word-break: break-word; }
.doc-item .doc-meta { font-size: .76rem; color: var(--muted); }
.doc-missing { font-size: .85rem; color: var(--muted); padding: .55rem .8rem; border: 1px dashed var(--line); border-radius: 10px; margin-bottom: .5rem; }

/* Modals with iframes */
.modal-content { border-radius: 14px; }
.frame-modal .modal-body { height: 78vh; }
.frame-modal iframe { border: 0; width: 100%; height: 100%; }
.confirm-icon { width: 52px; height: 52px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; background: var(--brand-50); color: var(--brand); }
.confirm-icon.danger { background: #fef3f2; color: #d92d20; }

/* Footer */
.app-footer { color: var(--muted); font-size: .8rem; padding: 1.25rem 0; border-top: 1px solid var(--line); margin-top: 2.5rem; background: var(--surface); }

/* Toasts */
.toast { border-radius: 10px; border: 0; box-shadow: 0 10px 30px rgba(16,24,40,.15); }

/* Login */
.login-page { background: radial-gradient(1000px circle at 0% 0%, #dfe8fa 0%, var(--canvas) 50%, #fff 100%); }
.login-shell { min-height: 100vh; display: flex; align-items: center; padding: 2rem 0; }
.login-card { border: 0; border-radius: 18px; overflow: hidden; box-shadow: 0 24px 60px rgba(16,24,40,.12); background: #fff; }
.login-brand { background: linear-gradient(150deg, #08306f 0%, var(--brand) 60%, #1c56b8 100%); color: #fff; position: relative; }
.login-brand .brand-badge { width: 84px; height: 84px; border-radius: 18px; background: rgba(255,255,255,.14); display: inline-flex; align-items: center; justify-content: center; }
.login-brand .brand-badge img { width: 70px; height: 70px; object-fit: contain; }
.login-brand .muted { color: rgba(255,255,255,.8); }
.login-brand .feature { display: flex; gap: .6rem; align-items: flex-start; font-size: .88rem; color: rgba(255,255,255,.88); margin-bottom: .6rem; }
.login-card .form-control { padding: .7rem .9rem; }
.login-card .btn-primary { padding: .7rem 1rem; font-weight: 600; }
