:root {
    --navy: #2b4e4f;
    --navy-light: #203b60;
    --navy-hover: #29496f;
    --primary: #16a6a1;
    --primary-light: #e5f6f5;
    --background: #f4f6fa;
    --surface: #ffffff;
    --text: #263449;
    --muted: #8793a5;
    --border: #e9edf3;
    --sidebar-width: 260px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Vazirmatn", Tahoma, sans-serif;
    background: var(--background);
    color: var(--text);
    font-size: 14px;
}

button, input, select, textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    text-decoration: none;
    color: inherit;
}

.app-layout {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    right: 0;
    background: var(--navy);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    height: 82px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 22px;
    border-bottom: 1px solid rgba(255,255,255,0.09);
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary);
    display: grid;
    place-items: center;
    font-size: 22px;
    font-weight: 800;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand-text strong {
    font-size: 15px;
}

.brand-text span {
    color: #a9bbd0;
    font-size: 11px;
}

.sidebar-menu {
    padding: 20px 12px;
    flex: 1;
    overflow-y: auto;
}

.menu-label {
    display: block;
    color: #8196af;
    font-size: 11px;
    padding: 14px 13px 9px;
}

.menu-item {
    min-height: 43px;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 10px 13px;
    margin: 3px 0;
    border-radius: 8px;
    color: #c3d0df;
    font-size: 13px;
    transition: 0.2s;
}

.menu-item span {
    width: 19px;
    text-align: center;
    font-size: 17px;
}

.menu-item:hover {
    background: var(--navy-hover);
    color: #fff;
}

.menu-item.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.sidebar-footer {
    padding: 18px;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.09);
    color: #8196af;
    font-size: 11px;
}

.main-content {
    width: calc(100% - var(--sidebar-width));
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    transition: 0.3s ease;
}

.topbar {
    height: 76px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-right, .topbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.breadcrumb {
    color: var(--muted);
    font-size: 13px;
}

.icon-button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 9px;
    color: var(--text);
    font-size: 18px;
}

.icon-button:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 11px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 16px;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-info strong {
    font-size: 12px;
}

.user-info span {
    color: var(--muted);
    font-size: 11px;
}

.page-content {
    padding: 30px;
    max-width: 1600px;
    margin: auto;
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 0 100vmax rgba(0,0,0,0.35);
    }

    .main-content {
        width: 100%;
        margin-right: 0;
    }

    .topbar {
        padding: 0 16px;
    }

    .page-content {
        padding: 20px 16px;
    }
}

@media (max-width: 500px) {
    .user-info {
        display: none;
    }

    .breadcrumb {
        font-size: 11px;
    }

    .topbar-right, .topbar-left {
        gap: 10px;
    }
}
.page-heading {
    margin-bottom: 25px;
}

.page-heading h1 {
    font-size: 23px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--navy);
}

.page-heading p {
    color: var(--muted);
    font-size: 13px;
}

.section-placeholder {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 45px 25px;
    text-align: center;
    margin-top: 20px;
}

.placeholder-icon {
    width: 65px;
    height: 65px;
    margin: 0 auto 18px;
    border-radius: 18px;
    background: var(--primary-light);
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 30px;
}

.section-placeholder h2 {
    font-size: 18px;
    color: var(--navy);
    margin-bottom: 12px;
}

.section-placeholder p {
    color: var(--muted);
    line-height: 2;
    max-width: 550px;
    margin: 0 auto 20px;
}

.development-status {
    display: inline-block;
    padding: 7px 15px;
    border-radius: 20px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
}

.dashboard-welcome {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dashboard-welcome h2 {
    color: var(--navy);
    margin-bottom: 10px;
    font-size: 20px;
}

.dashboard-welcome p {
    color: var(--muted);
}

.welcome-icon {
    font-size: 45px;
    color: var(--primary);
}


/* Sidebar colors */
.sidebar {
    background: #2b4e4f;
}

.menu-item.active {
    background: #6e7d66;
    color: #ffffff;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.menu-item.active:hover {
    background: #6e7d66;
}

.brand-icon {
    background: #6e7d66;
}

/* Theme selector */
.theme-control {
    color: var(--muted);
    font-size: 12px;
}

.theme-select {
    min-width: 125px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}

/* Dark theme */
:root[data-theme="dark"] {
    color-scheme: dark;
    --background: #171d21;
    --surface: #222b30;
    --text: #e6eceb;
    --muted: #a2b0ad;
    --border: #35423f;
    --navy: #e6eceb;
    --primary-light: #344640;
}

:root[data-theme="light"] {
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        color-scheme: dark;
        --background: #171d21;
        --surface: #222b30;
        --text: #e6eceb;
        --muted: #a2b0ad;
        --border: #35423f;
        --navy: #e6eceb;
        --primary-light: #344640;
    }
}

:root[data-theme="dark"] .icon-button,
:root[data-theme="dark"] .theme-select {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) .icon-button,
    :root:not([data-theme="light"]):not([data-theme="dark"]) .theme-select {
        background: var(--surface);
        color: var(--text);
        border-color: var(--border);
    }
}
/* Dark theme - Soft Sage */
:root[data-theme="dark"] {
    color-scheme: dark;
    --background: #252D29;
    --surface: #303A34;
    --text: #D5DED4;
    --muted: #AAB7AC;
    --border: #46534A;
    --navy: #D5DED4;
    --primary-light: #3B4D43;
}

:root[data-theme="light"] {
    color-scheme: light;
}

:root[data-theme="dark"] .sidebar {
    background: #304A45;
}

:root[data-theme="dark"] .menu-item {
    color: #C2CEC4;
}

:root[data-theme="dark"] .menu-item.active {
    background: #647A68;
    color: #FFFFFF;
}

:root[data-theme="dark"] .menu-item:hover:not(.active) {
    background: #3B554B;
    color: #FFFFFF;
}

:root[data-theme="dark"] .menu-label,
:root[data-theme="dark"] .sidebar-footer {
    color: #AAB7AC;
}

:root[data-theme="dark"] .brand-icon {
    background: #647A68;
}

:root[data-theme="dark"] .icon-button,
:root[data-theme="dark"] .theme-select {
    background: #303A34;
    color: #D5DED4;
    border-color: #46534A;
}

:root[data-theme="dark"] .user-avatar {
    background: #3B4D43;
    color: #D5DED4;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        color-scheme: dark;
        --background: #252D29;
        --surface: #303A34;
        --text: #D5DED4;
        --muted: #AAB7AC;
        --border: #46534A;
        --navy: #D5DED4;
        --primary-light: #3B4D43;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .sidebar {
        background: #304A45;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .menu-item {
        color: #C2CEC4;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .menu-item.active {
        background: #647A68;
        color: #FFFFFF;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .menu-item:hover:not(.active) {
        background: #3B554B;
        color: #FFFFFF;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .menu-label,
    :root:not([data-theme="light"]):not([data-theme="dark"]) .sidebar-footer {
        color: #AAB7AC;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .brand-icon {
        background: #647A68;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .icon-button,
    :root:not([data-theme="light"]):not([data-theme="dark"]) .theme-select {
        background: #303A34;
        color: #D5DED4;
        border-color: #46534A;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .user-avatar {
        background: #3B4D43;
        color: #D5DED4;
    }
}
/* Dark theme - Soft Sage */
:root[data-theme="dark"] {
    color-scheme: dark;
    --background: #252D29;
    --surface: #303A34;
    --text: #D5DED4;
    --muted: #AAB7AC;
    --border: #46534A;
    --navy: #D5DED4;
    --primary-light: #3B4D43;
}

:root[data-theme="light"] {
    color-scheme: light;
}

:root[data-theme="dark"] .sidebar {
    background: #304A45;
}

:root[data-theme="dark"] .menu-item {
    color: #C2CEC4;
}

:root[data-theme="dark"] .menu-item.active {
    background: #647A68;
    color: #FFFFFF;
}

:root[data-theme="dark"] .menu-item:hover:not(.active) {
    background: #3B554B;
    color: #FFFFFF;
}

:root[data-theme="dark"] .menu-label,
:root[data-theme="dark"] .sidebar-footer {
    color: #AAB7AC;
}

:root[data-theme="dark"] .brand-icon {
    background: #647A68;
}

:root[data-theme="dark"] .icon-button,
:root[data-theme="dark"] .theme-select {
    background: #303A34;
    color: #D5DED4;
    border-color: #46534A;
}

:root[data-theme="dark"] .user-avatar {
    background: #3B4D43;
    color: #D5DED4;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        color-scheme: dark;
        --background: #252D29;
        --surface: #303A34;
        --text: #D5DED4;
        --muted: #AAB7AC;
        --border: #46534A;
        --navy: #D5DED4;
        --primary-light: #3B4D43;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .sidebar {
        background: #304A45;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .menu-item {
        color: #C2CEC4;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .menu-item.active {
        background: #647A68;
        color: #FFFFFF;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .menu-item:hover:not(.active) {
        background: #3B554B;
        color: #FFFFFF;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .menu-label,
    :root:not([data-theme="light"]):not([data-theme="dark"]) .sidebar-footer {
        color: #AAB7AC;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .brand-icon {
        background: #647A68;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .icon-button,
    :root:not([data-theme="light"]):not([data-theme="dark"]) .theme-select {
        background: #303A34;
        color: #D5DED4;
        border-color: #46534A;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"]) .user-avatar {
        background: #3B4D43;
        color: #D5DED4;
    }
}

/* System messages */
.message-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.system-message {
    padding: 13px 16px;
    border-radius: 9px;
    font-size: 13px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.system-message.success {
    background: #e5f6ed;
    color: #24794c;
    border-color: #b8e4ca;
}

.system-message.error {
    background: #fceaea;
    color: #a43d3d;
    border-color: #efc4c4;
}

/* System messages */
.message-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.system-message {
    padding: 13px 16px;
    border-radius: 9px;
    font-size: 13px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.system-message.success {
    background: #e5f6ed;
    color: #24794c;
    border-color: #b8e4ca;
}

.system-message.error {
    background: #fceaea;
    color: #a43d3d;
    border-color: #efc4c4;
}

.letter-body { white-space: normal; overflow-wrap: anywhere; padding: 1rem; margin-block: .65rem; border: 1px solid var(--border); border-radius: .5rem; }
.table-wrap { overflow-x: auto; }
.management-table { width: 100%; border-collapse: collapse; }
.management-table :is(th, td) { text-align: start; padding: .7rem; border-block-end: 1px solid var(--border); }
.management-form :is(input:not([type=checkbox]), textarea, select) { max-width: 100%; width: min(100%, 42rem); }
.management-form label { display: block; margin-block: .5rem; }
.pagination { display: flex; gap: 1rem; margin-block: 1rem; }

:root {
    --control-border: #bdcdd4;
    --accent: #08756d;
    --action-text: #076a62;
    --field-error: #a61e32;
}
:root[data-theme="dark"] {
    --control-border: #5a7182;
    --accent: #08756d;
    --action-text: #74decd;
    --field-error: #ffacb5;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --control-border: #5a7182;
        --action-text: #74decd;
        --field-error: #ffacb5;
        color-scheme: dark;
    }
}
[hidden] { display: none !important; }
body { font-family: Tahoma, Arial, sans-serif; line-height: 1.65; }
:focus-visible { outline: 3px solid #218998; outline-offset: 3px; }
.main-content { min-width: 0; }
.page-content { padding-block: clamp(18px, 4vw, 36px); }
.page-content h1, .auth-card h1 { font-size: clamp(1.35rem, 2.4vw, 1.95rem); line-height: 1.4; overflow-wrap: anywhere; }
.page-content h2 { font-size: 1.05rem; margin-block: 1.6rem .65rem; }
.page-content :is(a:not(.primary-btn, .button-secondary, .action-button, .cancel-button), .text-action) {
    color: var(--text); text-decoration: none;
}
.page-content a { overflow-wrap: anywhere; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .85rem; margin-block-end: 1.25rem; }
.page-heading p { margin-top: .35rem; }
.workspace-panel, .correspondence-filters, .table-wrap, .management-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.workspace-panel { padding: clamp(14px, 3vw, 24px); }
.primary-btn, .button-secondary, .solar-panel button, .theme-select {
    min-height: 44px;
    border-radius: 8px;
}
.primary-btn, .button-secondary {
    display: inline-flex; align-items: center; justify-content: center; padding: .45rem .85rem;
    font-weight: 600; line-height: 1.4; text-align: center; cursor: pointer;
}
.primary-btn { background: var(--accent); border: 1px solid var(--accent); color: white; }
.primary-btn:hover { background: #075f58; }
.button-secondary { color: var(--text); background: var(--surface); border: 1px solid var(--control-border); }
.button-secondary:hover, .solar-panel button:hover { background: var(--primary-light); }
.skip-link { position: fixed; inset-block-start: .5rem; inset-inline-start: 1rem; z-index: 150; padding: .5rem; background: var(--surface); transform: translateY(-160%); }
.skip-link:focus { transform: none; }
#sidebarToggle { display: none; }
.drawer-overlay { position: fixed; inset: 0; background: rgb(5 18 29 / 52%); border: 0; z-index: 90; }
.sidebar { height: 100dvh; }
.sidebar-menu { overscroll-behavior: contain; }
.topbar-right { min-width: 0; }
.breadcrumb { color: var(--text); overflow-wrap: anywhere; }
.topbar-left { gap: .55rem; flex-shrink: 0; }
.topbar-left .user-info { max-width: 12ch; overflow-wrap: anywhere; }
.theme-select { max-width: 8rem; }
.correspondence-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: .8rem; align-items: start; padding: 1rem; margin-block-end: 1rem; }
.correspondence-filters label, .operation-field > label { display: grid; gap: .35rem; color: var(--text); font-weight: 600; }
.correspondence-filters :is(input, select), .management-form :is(input:not([type="checkbox"]), textarea, select) {
    display: block; width: 100%; min-height: 44px; min-width: 0;
    background: var(--surface); color: var(--text); border: 1px solid var(--control-border);
    border-radius: 8px; padding: .55rem .7rem;
}
.operation-form :is(input[type="file"], textarea) { max-width: 100%; }
.operation-form textarea { resize: vertical; }
.operation-form .primary-btn { margin-block-start: .85rem; }
.filter-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-self: end; }
.solar-control { position: relative; min-width: 0; }
.solar-control > label { margin-bottom: .35rem; }
.solar-input-row { display: flex; gap: .3rem; }
.solar-input-row input { text-align: center; }
.solar-input-row button { flex-shrink: 0; padding-inline: .55rem; }
.solar-panel {
    padding: .45rem; position: absolute; inset-inline-start: 0; inset-block-start: calc(100% + 4px); z-index: 15;
    width: min(15rem, calc(100vw - 3.5rem));
    font-size: .8125rem; line-height: 1.4; background: var(--surface); border: 1px solid var(--control-border);
    border-radius: 10px; box-shadow: 0 8px 30px rgb(17 38 52 / 18%);
}
.solar-heading { display: flex; align-items: center; justify-content: space-between; gap: .45rem; font-weight: 700; }
.solar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; margin-block: .3rem; }
.solar-panel button { padding-inline: .3rem; min-width: 0; border: 1px solid transparent; color: var(--text); background: var(--surface); }
.solar-panel button[aria-pressed="true"] { background: var(--accent); color: white; }
.solar-panel button[aria-current="date"] { border-color: var(--accent); }
.solar-panel button:disabled { opacity: .45; cursor: default; }
.field-error, .errorlist { color: var(--field-error); }
input[aria-invalid="true"] { border-color: var(--field-error); }
.errorlist { list-style-position: inside; margin-block: .4rem; }
.operation-grid, .letter-metadata { display: grid; gap: .75rem 1rem; }
.operation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.operation-wide { grid-column: 1 / -1; }
.operation-field > .inline-check { display: flex; align-items: center; gap: .5rem; }
.letter-metadata { grid-template-columns: minmax(7rem, 13rem) minmax(0, 1fr); overflow-wrap: anywhere; }
.letter-metadata dt { font-weight: 700; }
.letter-actions, .item-list { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; }
.letter-actions a, .item-list a { min-height: 44px; display: inline-flex; align-items: center; padding-inline: .7rem; border-radius: 8px; border: 1px solid var(--border); }
.responsive-records :is(th, td) { overflow-wrap: anywhere; }
.responsive-records thead { background: var(--background); }
.responsive-records tbody tr:hover { background: var(--background); }
.cell-label { display: none; }
.access-panel p { margin-block: .85rem; }
.access-panel :is(.primary-btn, .button-secondary) { margin-inline-end: .25rem; }
.auth-page { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: min(100%, 28rem); }
.auth-card p, .auth-card form { margin-block-start: .85rem; }
.auth-card label { margin-block: .5rem; }
.auth-card .primary-btn { width: 100%; margin-block-start: .6rem; }
@media (max-width: 900px) {
    #sidebarToggle { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; }
    .sidebar.open { box-shadow: none; }
    .sidebar:not(.open) { visibility: hidden; }
    .drawer-open { overflow: hidden; }
    .solar-panel { position: static; max-width: 100%; box-shadow: none; margin-block-start: .4rem; }
}
@media (max-width: 700px) {
    .topbar { min-height: 60px; height: auto; padding: .45rem .7rem; gap: .45rem; }
    .topbar-left .theme-control, .topbar-left .user-profile { display: none; }
    .topbar-left .theme-select { max-width: 5.8rem; }
    .operation-grid { grid-template-columns: minmax(0, 1fr); }
    .responsive-records, .responsive-records tbody { display: block; width: 100%; }
    .responsive-records thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .responsive-records tbody { display: grid; gap: .65rem; padding: .65rem; }
    .responsive-records tbody tr { display: grid; padding: .45rem .65rem; gap: .2rem; border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
    .responsive-records tbody td { display: grid; grid-template-columns: minmax(5rem, 32%) minmax(0, 1fr); gap: .4rem; padding: .25rem 0; border: 0; }
    .responsive-records tbody td[colspan] { display: block; }
    .cell-label { display: inline; font-weight: 700; }
    .cell-value { min-width: 0; }
    .org-stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)) !important; }
    :is(.table-scroll, .org-table-wrapper) { max-width: 100%; overflow-x: auto; }
}
@media (max-width: 390px) {
    .page-content { padding-inline: .75rem; }
    .page-heading { flex-wrap: wrap; }
    .topbar-left { gap: .3rem; }
    .logout-button { padding-inline: .5rem; }
}
@media (prefers-reduced-motion: reduce) {
    .sidebar, .main-content, .menu-item { transition: none; }
}

.letter-type-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin-block: .75rem; }
.letter-form-help { margin-block-end: 1rem; }
.letter-form-section { min-inline-size: 0; border: 0; padding: .55rem 0 1rem; margin-block: .7rem; }
.letter-form-section legend { font-weight: 700; font-size: 1.05rem; }
.letter-form-section + .letter-form-section { border-block-start: 1px solid var(--border); }
.letter-type-tabs .primary-btn { margin-block-start: 0; }
.advanced-filters { grid-column: 1 / -1; min-width: 0; }
.advanced-filters summary { cursor: pointer; color: var(--text); padding-block: .45rem; font-weight: 600; }
.advanced-filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: .75rem; padding-block: .5rem; }

/* Application surfaces and correspondence workspace */
:root, :root[data-theme="light"] {
    --background: #f4f7fb;
    --surface: #fff;
    --text: #19263a;
    --muted: #526378;
    --border: #dce4ef;
    --control-border: #c7d2e2;
    --primary-light: #e8f0ff;
    --accent: #68538f;
    --action-text: #1645b7;
    --sidebar-surface: #121e34;
    --sidebar-width: 236px;
    --menu-active: #293d63;
    --raised: #f7f9fc;
    --subtle-shadow: 0 5px 24px rgb(28 50 88 / 6%);
}
:root[data-theme="dark"] {
    --background: #101827;
    --surface: #172337;
    --text: #ebf0f8;
    --muted: #aab9cc;
    --border: #293a52;
    --control-border: #445774;
    --primary-light: #243a63;
    --accent: #68538f;
    --action-text: #aac2ff;
    --sidebar-surface: #0b1424;
    --menu-active: #243857;
    --raised: #131e30;
    --subtle-shadow: none;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --background: #101827;
        --surface: #172337;
        --text: #ebf0f8;
        --muted: #aab9cc;
        --border: #293a52;
        --control-border: #445774;
        --primary-light: #243a63;
        --accent: #68538f;
        --action-text: #aac2ff;
        --sidebar-surface: #0b1424;
        --menu-active: #243857;
        --raised: #131e30;
        --subtle-shadow: none;
    }
}
:root .sidebar { background: var(--sidebar-surface); }
:root .sidebar .menu-item { color: #d1dced; }
:root .sidebar .menu-item.active, :root .sidebar .menu-item:hover {
    background: var(--menu-active);
    color: #fff;
}
:root .sidebar .menu-item.active { box-shadow: inset -3px 0 #7196ff; }
:root .sidebar .brand-icon { background: #2d56c5; color: #fff; }
:root .sidebar .menu-label { color: #a1b1cb; }
.sidebar-header { min-height: 72px; }
.topbar { height: 64px; }
:root .topbar :is(.icon-button, .theme-select) { color: var(--text); background: var(--surface); border-color: var(--control-border); }
:root .topbar .user-avatar { background: var(--primary-light); color: var(--action-text); }
.primary-btn:hover { background: #123fbb; }
.records-workspace { max-width: 72rem; margin-inline: auto; }
.records-heading { align-items: center; margin-block-end: 1.25rem; }
.new-letter-button { gap: .4rem; min-height: 46px; padding-inline: 1rem; }
.new-letter-button span { font-size: 1.1rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.correspondence-filters { display: block; padding: .9rem; margin-block-end: 1.15rem; box-shadow: var(--subtle-shadow); }
.search-strip { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; }
.search-strip .search-box { display: flex; position: relative; align-items: center; }
.search-box > span[aria-hidden] { position: absolute; inset-inline-start: .75rem; font-size: 1.35rem; color: var(--muted); pointer-events: none; }
.search-strip .search-box input { padding-inline-start: 2.2rem; background: var(--raised); }
.advanced-filters { margin-block-start: .55rem; }
.advanced-filters summary { min-height: 44px; padding: .5rem .25rem; }
.advanced-filters[open] .advanced-filter-grid { padding-block: .75rem; border-block-start: 1px solid var(--border); }
.filter-apply { margin-block-start: .35rem; }
.filter-reset { display: inline-flex; align-items: center; min-height: 44px; margin-block-start: .25rem; }
.records-table { box-shadow: var(--subtle-shadow); }
.records-table .responsive-records thead { background: var(--raised); }
.records-table .responsive-records :is(th,td) { padding-block: .9rem; }
.letter-status { display: inline-block; border-radius: 6px; padding: .18rem .5rem; font-size: .8rem; background: var(--raised); border: 1px solid var(--border); color: var(--text); }
.letter-status:is(.status-registered,.status-approved,.status-sent) { background: var(--primary-light); color: var(--action-text); }
.records-empty { min-height: 18rem; padding: 2rem 1rem; display: grid; justify-items: center; align-content: center; gap: .65rem; text-align: center; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--subtle-shadow); }
.records-empty h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.records-empty .empty-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--primary-light); color: var(--action-text); font-size: 1.35rem; }
.records-empty a { display: inline-flex; align-items: center; min-height: 44px; }
@media (max-width: 700px) {
    .topbar { min-height: 60px; height: auto; }
    .records-heading { margin-block-end: 1rem; }
    .records-empty { min-height: 14rem; }
    .records-table .responsive-records td { padding-block: .25rem; }
}

@font-face {
    font-family: "Noto Sans Arabic";
    src: url("../fonts/NotoSansArabic-Regular.ttf") format("truetype");
    font-weight: 400 500;
    font-display: swap;
}
@font-face {
    font-family: "Noto Sans Arabic";
    src: url("../fonts/NotoSansArabic-Bold.ttf") format("truetype");
    font-weight: 600 800;
    font-display: swap;
}
:root { --sidebar-width: 196px; }
body { font-family: "Noto Sans Arabic", Tahoma, sans-serif; font-size: 12px; line-height: 1.7; }
:root .topbar { height: 48px; padding-inline: 1rem; }
:root .sidebar-header { height: 56px; min-height: 56px; padding-inline: 12px; gap: 8px; }
:root .sidebar .brand-icon { width: 30px; height: 30px; font-size: 15px; border-radius: 7px; }
.brand-text strong { font-size: 12px; }
.brand-text span { font-size: 9px; }
:root .sidebar-menu { padding: .45rem .5rem; }
:root .sidebar .menu-item { min-height: 32px; gap: .5rem; margin-block: 1px; padding: .28rem .6rem; font-size: 11px; border-radius: 6px; }
:root .sidebar .menu-item span { font-size: 13px; width: 15px; }
:root .sidebar .menu-label { padding: .6rem .6rem .25rem; font-size: 9px; }
.page-content { padding: 18px 20px; }
.page-content h1, .auth-card h1 { font-size: 20px; }
.page-content h2 { font-size: 14px; margin-block: 1rem .4rem; }
.page-heading { margin-block-end: .8rem; }
.topbar .breadcrumb, .topbar .user-info strong { font-size: 11px; }
.topbar .user-avatar { width: 30px; height: 30px; font-size: 13px; }
.topbar .user-info span { font-size: 9px; }
.primary-btn, .button-secondary, .new-letter-button, .theme-select, .filter-reset,
.advanced-filters summary, .solar-panel button, .letter-actions a, .item-list a { min-height: 33px; }
.primary-btn, .button-secondary { padding: .22rem .6rem; font-size: 11px; }
.correspondence-filters { padding: .65rem; margin-block-end: .8rem; }
.correspondence-filters :is(input,select), .management-form :is(input:not([type="checkbox"]),textarea,select) {
    min-height: 34px; padding-block: .25rem; font-size: 12px;
}
.records-table .responsive-records :is(th,td), .management-table :is(th,td) { padding-block: .5rem; }
.records-empty { min-height: 9rem; padding: 1rem .7rem; gap: .35rem; }
.records-empty h2 { margin: 0; font-size: 13px; }
.records-empty .empty-icon { width: 32px; height: 32px; font-size: 15px; border-radius: 7px; }
.records-empty a { min-height: 32px; }
.workspace-panel { padding: 12px; }
.operation-grid { gap: .55rem .85rem; }
.letter-form-section { padding-block: .35rem .7rem; margin-block: .45rem; }
.letter-form-section legend { font-size: 13px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,16rem),1fr)); gap: .75rem; }
.settings-grid h2 { margin-block-start: 0; }
.settings-links { list-style: none; }
.settings-links a { display: inline-flex; min-height: 32px; align-items: center; }
@media (max-width: 700px) {
    :root .topbar { height: auto; min-height: 48px; padding-inline: .6rem; }
    .page-content { padding: 12px; }
    .page-content h1 { font-size: 17px; }
    .primary-btn, .button-secondary, .theme-select, .solar-panel button, .settings-links a,
    :root .sidebar .menu-item { min-height: 40px; }
    .records-table .responsive-records td { padding-block: .2rem; }
}

/* Compact dashboard with an indigo sidebar and colored shortcuts. */
:root[data-theme="dark"] {
    --background: #111827;
    --surface: #1c2635;
    --raised: #151e2c;
    --border: #344155;
    --sidebar-surface: #1c2635;
    --menu-active: #223456;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --background: #111827;
        --surface: #1c2635;
        --raised: #151e2c;
        --border: #344155;
        --sidebar-surface: #1c2635;
        --menu-active: #223456;
    }
}
:root[data-theme="dark"] .sidebar,
:root:not([data-theme="light"]) .sidebar { background: var(--sidebar-surface); }
.office-dashboard { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:14px; align-items:start; }
.office-shortcuts { display:grid; gap:12px; }
.page-content a.office-card { display:flex; min-height:79px; align-items:center; gap:11px; padding:12px; border-radius:11px; text-decoration:none; color:#fff; }
.office-card-purple { background:linear-gradient(105deg,#211333,#301a50); border:1px solid #7849bc; }
.office-card-blue { background:linear-gradient(105deg,#142245,#1e3661); border:1px solid #476fdc; }
.page-content a.office-card:hover { transform:translateY(-2px); filter:brightness(1.16); }
.office-icon { display:grid; place-items:center; width:42px; height:42px; flex:0 0 42px; border-radius:10px; font:23px/1 Arial,sans-serif; color:#fff; background:linear-gradient(135deg,#965dff,#7429ca); }
.office-card-blue .office-icon { background:linear-gradient(135deg,#388dff,#5044ed); }
.office-card-text { min-width:0; display:grid; flex:1; }
.office-card-text strong { font-size:14px; }
.office-card-text span { color:#e2d6fa; font-size:11px; }
.office-card-blue .office-card-text span { color:#d2e2ff; }
.office-count { min-width:34px; text-align:center; padding:2px 6px; border-radius:7px; background:#ffffff1a; font-size:18px; }
.office-recent header { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-block-end:6px; }
.office-recent header h2 { margin:0; }
.office-recent ul { list-style:none; margin:0; padding:0; }
.office-recent li + li { border-block-start:1px solid var(--border); }
.page-content .office-recent li a { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px 0; text-decoration:none; }
.office-empty,.registry-auto-note { color:var(--muted); padding-block:6px; }
@media (max-width:760px) { .office-dashboard { grid-template-columns:1fr; } }
@media (prefers-reduced-motion:reduce) { .page-content a.office-card:hover { transform:none; } }

/* Dashboard spacing */
.office-dashboard { gap: 24px; }
.office-shortcuts { gap: 16px; }
.page-content a.office-card { gap: 14px; min-height: 92px; padding: 16px; }
.office-card-text { gap: 3px; overflow-wrap: anywhere; }
.office-count { flex: 0 0 auto; }
.office-recent { padding: 16px; }
.office-recent header { gap: 12px; margin-block-end: 14px; }
.page-content .office-recent li a { padding-block: 11px; }
@media (max-width:760px) {
    .office-dashboard { gap: 18px; }
    .office-shortcuts { gap: 12px; }
    .page-content a.office-card { min-height: 76px; padding: 12px; gap: 10px; }
}
@media (max-width:380px) {
}

/* Dashboard and administration navigation. */
.primary-btn:hover { background:#574478; }
:root .sidebar .menu-item.active { background:#4a3e62; box-shadow: inset -3px 0 #b8a4dd; }
:root .sidebar .brand-icon { background:#68538f; }
.page-content :is(a, .text-action):hover { text-decoration:none; }
.page-content :is(a:not(.primary-btn,.button-secondary,.action-button,.cancel-button),.text-action):hover { background-color:var(--raised); }
.office-dashboard { grid-template-columns:minmax(0,1fr); gap:18px; }
.office-shortcuts { grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.page-content a.office-card {
    color:var(--text); background:var(--surface); border:1px solid var(--border);
    box-shadow:var(--subtle-shadow); min-height:100px; filter:none;
}
.page-content a.office-card:hover { background:var(--raised); transform:none; }
.office-card-text span, .office-card-blue .office-card-text span { color:var(--muted); }
.office-card-purple .office-icon { background:#275d5b; }
.office-card-blue .office-icon { background:#574478; }
.office-card-neutral .office-icon { background:#304b59; }
.office-count { background:var(--raised); }
.office-card-arrow { color:var(--muted); font-size:22px; line-height:1; }
.office-icon svg, .management-menu-icon svg { width:22px; height:22px; display:block; }
.management-menu-heading { margin-block-end:16px; }
.management-menu-heading p { color:var(--muted); margin-block-start:4px; }
.management-menu-list { padding:0; margin:0; list-style:none; display:grid; gap:10px; }
.page-content a.management-menu-link {
    display:flex; align-items:center; gap:12px; padding:10px 13px;
    border:1px solid var(--border); border-radius:10px; background:var(--surface); color:var(--text);
    text-decoration:none; min-height:65px;
}
.page-content a.management-menu-link:hover { border-color:var(--control-border); }
.management-menu-icon { display:grid; place-items:center; width:40px; height:40px; flex:0 0 40px; border-radius:9px; background:var(--raised); }
.management-menu-text { flex:1; min-width:0; display:grid; gap:2px; }
.management-menu-text strong { font-size:14px; }
.management-menu-text span, .management-menu-arrow { color:var(--muted); }
.management-menu-arrow { font-size:24px; line-height:1; }
@media (max-width:760px) {
    .office-shortcuts { grid-template-columns:minmax(0,1fr); gap:10px; }
    .page-content a.office-card { min-height:70px; }
}

.operation-field[hidden] { display: none; }
.destination-unit-summary { color: var(--muted, inherit); margin: .45rem 0 0; }
.destination-unit-summary:empty { display: none; }
.operation-field input[readonly] { opacity: .82; }

.operation-field select[hidden], .destination-options label[hidden] { display: none; }
.destination-options { max-height: 13rem; overflow: auto; margin-top: .35rem; }
.destination-options label { display: flex; align-items: center; gap: .5rem; padding: .35rem .2rem; cursor: pointer; }
.destination-options input[type="checkbox"] { width: auto; min-height: 0; margin: 0; }

body { font-size: 14px; line-height: 1.75; }
.page-heading h1 { font-size: clamp(20px, 2vw, 25px); line-height: 1.5; }
.operation-form :is(input, select, textarea, button) { font-size: 14px; }
.letter-heading-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.letter-edit-button { border: 1px solid currentColor; padding: .4rem .85rem; font-size: 15px; font-weight: 700; }
.letter-edit-button:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.registration-form { display: grid; gap: .95rem; }
.registration-form .registration-field { min-width: 0; }
.registration-form .registration-field label { display: block; margin-block-end: .3rem; font-weight: 700; font-size: .875rem; }
.registration-form .registration-field input { font-size: .9375rem; min-height: 40px; }
.registration-help { margin-block-start: .45rem; color: var(--muted); font-size: .8125rem; line-height: 1.8; overflow-wrap: anywhere; }
.registration-form .errorlist { padding-inline-start: 1.15rem; margin-block: .4rem 0; }

.app-brand .brand-mark {
    position: relative;
    display: block;
    flex: 0 0 38px;
    width: 38px;
    height: 44px;
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
}
.brand-mark img { position: absolute; inset: -16px auto auto -190px; width: 235px; max-width: none; height: auto; }
:root .topbar { min-height: 60px; height: auto; padding-block: .45rem; }
:root .topbar .breadcrumb { font-size: .86rem; }
.account-menu { position: relative; }
.account-menu summary {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .3rem .55rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    cursor: pointer;
    list-style: none;
}
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary:hover, .account-menu[open] summary { background: var(--raised); }
.account-name { max-width: min(26ch, 32vw); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.account-chevron { width: 6px; height: 6px; border: solid currentColor; border-width: 0 0 1px 1px; transform: rotate(-45deg); margin-inline: .2rem; }
.account-menu[open] .account-chevron { transform: rotate(135deg); }
.account-panel {
    position: absolute;
    inset: calc(100% + .45rem) auto auto 0;
    z-index: 60;
    display: grid;
    gap: .5rem;
    width: min(15rem, 85vw);
    padding: .85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 28px #0003;
}
.account-username { font-weight: 700; overflow-wrap: anywhere; border-bottom: 1px solid var(--border); padding-bottom: .35rem; }
.account-panel .theme-select, .account-panel .logout-button { width: 100%; max-width: none; min-height: 36px; font-size: .85rem; }
.signature-settings { max-width: 40rem; padding: 1rem; }
.signature-settings form { margin-top: 1rem; }
.signature-preview { width: min(100%, 16rem); padding: .5rem; margin-block: .75rem; border-radius: .5rem; background: #fff; }
.signature-preview img { display: block; max-width: 100%; max-height: 7rem; margin: auto; }

.account-panel {
    font-size: .75rem;
    font-weight: 400;
    line-height: 1.5;
    gap: .55rem;
}
.account-menu summary { font-size: .75rem; line-height: 1.5; }
.account-panel :is(.button-secondary, .theme-select) {
    font-family: inherit;
    font-size: inherit;
    font-weight: 500;
    line-height: inherit;
    min-height: 38px;
    height: auto;
    padding: .375rem .65rem;
}
.account-panel .button-secondary { width: 100%; display: flex; justify-content: center; align-items: center; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
@media (max-width: 700px) { .profile-grid { grid-template-columns: minmax(0, 1fr); } }


.account-menu .user-avatar, .profile-identity .user-avatar { overflow: hidden; flex-shrink: 0; }
.account-menu .user-avatar img, .profile-identity .user-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.profile-identity { display: flex; align-items: center; gap: .75rem; margin-block: .75rem; }
.profile-identity .profile-avatar { width: 64px; height: 64px; }
:root .topbar .account-panel .theme-select { font-size: inherit; }


.solar-control .solar-panel button {
    min-height: 28px;
    padding: .1rem .3rem;
    font-size: inherit;
    line-height: inherit;
    border-radius: 6px;
}
.solar-control .solar-panel .solar-heading button { min-width: 28px; }
@media (pointer: coarse) {
    .solar-panel { width: min(16rem, calc(100vw - 3.5rem)); }
    .solar-control .solar-panel button { min-height: 34px; }
}

/* Shared controls used by the correspondence workspace. */
.drawer-close:not([hidden]) { display: inline-flex; margin: .5rem .8rem; }
.dashboard-letter-meta { display: block; color: var(--muted); font-size: .83rem; }
.letter-type-tabs a[aria-current="page"] { font-weight: 700; border-color: var(--action-text); }
.workspace-badge { display: inline-block; padding: .15rem .45rem; border: 1px solid var(--border); border-radius: .35rem; }
.workspace-badge-warning { color: var(--text); border-color: #b87720; font-weight: 700; }
.destination-selected { color: var(--muted); margin-block: .25rem; padding-inline-start: 1.25rem; }
.settings-permissions label[hidden] { display: none; }
[data-image-preview]:not([hidden]) { display: block; max-width: 100%; background: #fff; border: 1px solid var(--border); border-radius: .35rem; }
@media (pointer: coarse) {
    .letter-type-tabs :is(a, button), .mail-alerts summary, .account-menu summary,
    .operation-form :is(input:not([type="checkbox"]), select, .primary-btn) { min-height: 44px; }
}
