:root {
    --bg: #f6f8fb;
    --panel: #ffffff;
    --panel-soft: #eef4f8;
    --ink: #18242d;
    --muted: #5b6c78;
    --line: #d7e0e7;
    --brand: #0b6f63;
    --brand-2: #154e86;
    --danger: #aa2f2f;
    --input-bg: #ffffff;
    --table-head: #f8fafc;
    --header-bg: #0d2230;
    --tab-bg: #e5edf3;
    --tab-text: #18242d;
    --shadow: 0 16px 42px rgba(25, 42, 60, 0.08);
}

body[data-theme="dark"] {
    --bg: #0f151b;
    --panel: #18232c;
    --panel-soft: #202d38;
    --ink: #edf4f7;
    --muted: #aab8c4;
    --line: #344653;
    --brand: #1b8d7c;
    --brand-2: #2c6aa4;
    --danger: #c45757;
    --input-bg: #111a22;
    --table-head: #202d38;
    --header-bg: #091119;
    --tab-bg: #dce8f0;
    --tab-text: #101820;
    --shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
.nav-button {
    font: inherit;
}

button,
.file-button,
.nav-button {
    border: 0;
    border-radius: 7px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

button:hover,
.file-button:hover,
.nav-button:hover {
    filter: brightness(0.96);
    text-decoration: none;
}

button.secondary,
.nav-button.secondary {
    background: var(--brand-2);
}

button.danger {
    background: var(--danger);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--input-bg);
    color: var(--ink);
    min-height: 38px;
    padding: 8px 10px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(1.8rem, 4vw, 3rem);
    margin-bottom: 0;
}

h2 {
    font-size: 1.12rem;
    margin-bottom: 8px;
}

p {
    color: var(--muted);
    line-height: 1.6;
}

.first-use-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    background: rgba(13, 34, 48, 0.78);
    padding: 22px;
}

.first-use-modal[hidden] {
    display: none;
}

.first-use-card {
    width: min(760px, 100%);
    max-height: min(860px, 92vh);
    overflow: auto;
    background: var(--panel);
    border-radius: 8px;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.24);
    padding: 24px;
}

.first-use-card h2 {
    font-size: clamp(1.35rem, 3vw, 1.9rem);
    margin-bottom: 12px;
}

.first-use-card ul {
    margin: 0 0 18px;
    padding-left: 20px;
    color: var(--ink);
}

.first-use-card li {
    margin-bottom: 10px;
    line-height: 1.55;
}

.confirm-check {
    align-items: start;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    display: grid;
    gap: 10px;
    grid-template-columns: auto 1fr;
    padding: 12px;
}

.confirm-check input {
    inline-size: 18px;
    block-size: 18px;
    min-height: 0;
    margin-top: 2px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

.app-header {
    background: var(--header-bg);
    color: #fff;
    padding: 28px min(4vw, 42px);
}

.header-inner {
    display: grid;
    grid-template-columns: minmax(250px, 1fr) minmax(920px, 1.2fr);
    gap: 28px;
    align-items: center;
    max-width: 1440px;
    margin: 0 auto;
}

.eyebrow {
    color: #9ed5c9;
    margin-bottom: 8px;
    text-transform: uppercase;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.login-box {
    display: grid;
    grid-template-columns: minmax(220px, 1.15fr) minmax(200px, 1fr) max-content max-content max-content;
    gap: 12px;
    align-items: end;
    width: 100%;
}

.login-box label {
    color: #d6e4ec;
    min-width: 0;
}

.login-box input {
    min-height: 52px;
    padding: 12px 14px;
}

.login-box button,
.login-box .nav-button {
    min-height: 52px;
    padding-inline: 18px;
}

.layout {
    display: grid;
    grid-template-columns: 310px minmax(0, 1fr);
    gap: 24px;
    align-items: stretch;
    padding: 24px min(4vw, 42px);
    max-width: 1440px;
    margin: 0 auto;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.workspace {
    display: grid;
    gap: 16px;
    align-content: start;
}

.settings-panel,
.ad-slot,
.panel,
.status-strip {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.settings-panel,
.ad-slot {
    border-radius: 8px;
    padding: 16px;
}

.settings-panel {
    display: grid;
    gap: 12px;
    flex: 1;
    align-content: start;
}

.ad-slot {
    min-height: 250px;
    display: grid;
    place-items: center;
    color: var(--muted);
    border-style: dashed;
}

.ad-slot span {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.adsbygoogle {
    width: 100%;
    min-height: 250px;
}

.tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.tab {
    background: var(--tab-bg);
    color: var(--tab-text);
    min-width: 116px;
}

.tab.active {
    background: var(--brand-2);
    color: #fff;
}

.status-strip {
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    gap: 14px;
    color: var(--muted);
    font-size: 0.9rem;
}

.panel {
    display: none;
    border-radius: 8px;
    overflow: hidden;
}

.panel.active {
    display: block;
}

.tool-head {
    padding: 18px;
    display: grid;
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    border-bottom: 1px solid var(--line);
}

.tool-head > div:first-child {
    min-width: 0;
}

.tool-head p {
    margin-bottom: 0;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

#employeesPanel .tool-head {
    grid-template-columns: 1fr;
}

#employeesPanel .actions {
    justify-content: flex-start;
}

.file-button input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
    pointer-events: none;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 10px;
    padding: 14px 18px;
    background: var(--panel-soft);
    border-bottom: 1px solid var(--line);
}

.metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 12px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.metric strong {
    display: block;
    margin-top: 4px;
    font-size: 1.1rem;
}

.table-controls {
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(220px, 1fr) auto;
    padding: 14px 18px;
}

.table-controls label,
.pagination-controls label {
    align-items: center;
    display: flex;
    flex-direction: row;
    gap: 8px;
    white-space: nowrap;
}

.table-controls input {
    min-width: 240px;
}

.pagination-controls {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.pagination-controls label {
    min-width: 112px;
}

.pagination-controls select {
    min-width: 86px;
}

.pagination-controls span {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.pagination-controls button {
    min-height: 36px;
}

.table-wrap {
    overflow: auto;
    max-height: 560px;
}

table {
    border-collapse: collapse;
    width: 100%;
    min-width: 980px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    font-size: 0.86rem;
}

th {
    background: var(--table-head);
    position: sticky;
    top: 0;
    z-index: 1;
}

td.number,
th.number {
    text-align: right;
}

.editor-grid {
    padding: 18px;
    display: block;
}

.inline-editor-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: auto;
    max-height: 640px;
}

.editor-table {
    min-width: 1560px;
}

.editor-table th,
.editor-table td {
    padding: 8px;
}

.editor-table input {
    min-width: 96px;
    min-height: 34px;
    padding: 6px 8px;
}

.editor-table input[name="name"] {
    min-width: 180px;
}

.editor-table .remove-row {
    background: #485766;
    min-height: 34px;
    padding: 0 10px;
}

.history-list,
.account-grid,
.backup-grid,
.contact-grid {
    padding: 18px;
    display: grid;
    gap: 10px;
}

.account-grid,
.backup-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.account-card,
.backup-card,
.contact-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    display: grid;
    gap: 10px;
}

.account-card h3,
.backup-card h3 {
    margin: 0;
    font-size: 1rem;
}

.account-card p,
.backup-card p,
.contact-card span {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.notice {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    padding: 10px;
    font-size: 0.88rem;
}

.history-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    gap: 18px;
}

.history-item strong {
    display: block;
}

.app-footer {
    padding: 0 min(4vw, 42px) 26px;
    max-width: 1440px;
    margin: 0 auto;
}

.app-footer p {
    font-size: 0.85rem;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin: 12px 0;
}

.footer-links a {
    color: var(--accent);
    font-size: 0.88rem;
    font-weight: 800;
}

.developer-credit {
    color: var(--ink);
    font-weight: 800;
    margin-bottom: 0;
}

@media (max-width: 1320px) {
    .header-inner {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .login-box {
        grid-template-columns: minmax(240px, 1fr) minmax(220px, 1fr) max-content max-content max-content;
    }
}

@media (max-width: 1050px) {
    .header-inner,
    .layout,
    .tool-head,
    .table-controls {
        grid-template-columns: 1fr;
    }

    .login-box {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .actions {
        justify-content: flex-start;
    }

    .settings-panel {
        flex: initial;
    }

    .summary-grid,
    .account-grid,
    .backup-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    body {
        overflow-x: hidden;
    }

    .app-header {
        padding-inline: 14px;
    }

    .layout {
        padding: 16px 14px;
        width: 100%;
    }

    .workspace,
    .panel,
    .status-strip,
    .table-controls,
    .tool-head {
        min-width: 0;
        width: 100%;
    }

    .tabs {
        margin-inline: -2px;
        padding-inline: 2px;
        scroll-padding-inline: 14px;
    }

    .tab {
        min-width: max-content;
        padding-inline: 16px;
    }

    .tool-head,
    .table-controls,
    .history-list,
    .account-grid,
    .backup-grid,
    .contact-grid {
        padding-left: 14px;
        padding-right: 14px;
    }

    .login-box,
    .summary-grid,
    .account-grid,
    .backup-grid {
        grid-template-columns: 1fr;
    }

    .status-strip,
    .pagination-controls,
    .history-item {
        display: grid;
        justify-content: stretch;
    }

    .table-controls label,
    .pagination-controls label {
        align-items: stretch;
        flex-direction: column;
        white-space: normal;
    }

    .table-controls input {
        min-width: 0;
    }

    button,
    .file-button,
    .nav-button {
        width: 100%;
    }
}
