:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-muted: #eef2f6;
    --text: #17202a;
    --muted: #697586;
    --line: #d9e0e7;
    --primary: #0f766e;
    --primary-strong: #115e59;
    --accent: #2563eb;
    --shadow: 0 18px 42px rgba(17, 24, 39, 0.12);
    --sidebar-width: 280px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px 16px;
    background: #111827;
    color: #f8fafc;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    margin-bottom: 28px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font-size: 14px;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 18px;
}

.brand small {
    margin-top: 2px;
    color: #b6c2d1;
    font-size: 12px;
}

.nav-list {
    display: grid;
    gap: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #d6deea;
    text-decoration: none;
    font-size: 15px;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.nav-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
}

.main-area {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 76px;
    padding: 16px 28px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.logout-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-menu {
    position: relative;
    margin-left: auto;
}

.notification-menu summary {
    position: relative;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    list-style: none;
}

.notification-menu summary::-webkit-details-marker {
    display: none;
}

.bell-icon {
    width: 16px;
    height: 16px;
    border: 2px solid var(--text);
    border-radius: 10px 10px 5px 5px;
    border-bottom-width: 3px;
}

.notification-menu summary strong {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 20px;
    height: 20px;
    padding: 2px 5px;
    border-radius: 999px;
    background: #dc2626;
    color: #ffffff;
    font-size: 11px;
    line-height: 16px;
    text-align: center;
}

.notification-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 50;
    width: min(380px, calc(100vw - 24px));
    max-height: 460px;
    overflow: auto;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.notification-panel header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.notification-panel h2,
.notification-panel p {
    margin: 0;
}

.notification-panel h2 {
    font-size: 16px;
}

.notification-panel button {
    border: 0;
    background: transparent;
    color: var(--primary-strong);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.notification-list {
    display: grid;
    gap: 8px;
}

.notification-item button {
    display: grid;
    width: 100%;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    text-align: left;
}

.notification-item.unread button {
    border-color: rgba(15, 118, 110, 0.45);
    background: #ecfdf5;
}

.notification-item small {
    color: var(--muted);
}

.logout-form span {
    color: var(--muted);
    font-size: 13px;
}

.logout-form button,
.actions button {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    cursor: pointer;
    font: inherit;
}

.logout-form button {
    min-height: 36px;
    padding: 7px 12px;
}

.topbar h1,
.topbar p {
    margin: 0;
}

.topbar h1 {
    font-size: 24px;
    line-height: 1.2;
}

.topbar-kicker {
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 13px;
}

.content {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 28px;
}

.empty-state {
    display: grid;
    justify-items: center;
    align-content: center;
    min-height: calc(100vh - 132px);
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin-bottom: 18px;
    border-radius: 8px;
    background: var(--surface-muted);
    color: var(--primary-strong);
    font-size: 15px;
    font-weight: 800;
}

.empty-state h2 {
    max-width: 760px;
    margin: 0 0 10px;
    font-size: clamp(22px, 4vw, 32px);
    line-height: 1.2;
}

.empty-state p {
    max-width: 660px;
    margin: 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.6;
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    margin-top: 20px;
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
}

.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: 0;
    border-radius: 8px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.primary-button {
    background: var(--primary);
    color: #ffffff;
}

.secondary-button {
    background: var(--surface-muted);
    color: var(--text);
}

.panel,
.login-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.panel {
    padding: 22px;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-header h2,
.panel-header p {
    margin: 0;
}

.panel-header h2 {
    font-size: 22px;
    line-height: 1.25;
}

.panel-header p,
.form-note {
    margin-top: 5px;
    color: var(--muted);
    line-height: 1.5;
}

.split-panel {
    display: grid;
    grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-grid.single {
    grid-template-columns: 1fr;
}

.form-grid label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
}

.form-grid textarea {
    min-height: 96px;
    resize: vertical;
}

.check-line {
    display: flex !important;
    align-items: center;
    gap: 9px;
    color: var(--text) !important;
}

.check-line input {
    width: 18px;
    min-height: 18px;
}

.check-line small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-weight: 400;
}

.form-actions,
.permission-box,
.full-span {
    grid-column: 1 / -1;
}

.document-form select[multiple] {
    min-height: 126px;
}

.permission-box {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.config-box,
.rule-summary {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.permission-box h3 {
    margin: 0 0 12px;
    font-size: 17px;
}

.config-box h3,
.rule-summary h3 {
    margin: 0 0 12px;
    font-size: 17px;
}

.config-box {
    display: grid;
    gap: 12px;
}

.rule-summary ul {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    line-height: 1.55;
}

.permission-box h4 {
    margin: 16px 0 10px;
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
}

.permission-box h4:first-of-type {
    margin-top: 0;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-list span {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.filter-bar a {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
}

.filter-bar a.active {
    background: var(--primary);
    color: #ffffff;
}

.text-danger {
    color: #b91c1c !important;
}

.text-warning {
    color: #92400e !important;
}

.revision-list {
    display: grid;
    gap: 14px;
}

.revision-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.revision-card header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.revision-card h3 {
    margin: 4px 0 0;
    font-size: 18px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.data-table th,
.data-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.data-table td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status.on {
    background: #dcfce7;
    color: #166534;
}

.status.off {
    background: #fee2e2;
    color: #991b1b;
}

.status.neutral {
    background: #e0f2fe;
    color: #075985;
}

.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: 0;
    border-radius: 8px;
    background: #dc2626;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.workflow-board {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.task-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.task-card header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.task-card h3 {
    margin: 4px 0 0;
    font-size: 18px;
    line-height: 1.3;
}

.task-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

.task-meta div {
    padding: 10px;
    border-radius: 8px;
    background: var(--surface-muted);
}

.task-meta dt,
.task-meta dd {
    margin: 0;
}

.task-meta dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.task-meta dd {
    margin-top: 3px;
}

.task-comment {
    margin: 0;
    padding: 10px;
    border-left: 3px solid var(--primary);
    background: #f8fafc;
    color: var(--muted);
}

.task-actions {
    display: grid;
    gap: 10px;
}

.task-actions textarea {
    width: 100%;
    min-height: 76px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
}

.task-actions div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.empty-state.compact {
    min-height: 260px;
    margin-top: 16px;
}

.actions {
    white-space: nowrap;
}

.actions a,
.actions button {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 10px;
    color: var(--primary-strong);
    text-decoration: none;
}

.actions form {
    display: inline;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #f8fafc 0%, #e8eef5 100%);
}

.auth-shell {
    width: min(420px, 100%);
}

.login-panel {
    padding: 28px;
    box-shadow: var(--shadow);
}

.login-brand {
    color: var(--text);
    margin-bottom: 24px;
}

.login-brand small {
    color: var(--muted);
}

.login-panel h1 {
    margin: 0;
    font-size: 28px;
}

.alert {
    padding: 12px 14px;
    margin: 18px 0;
    border-radius: 8px;
    font-weight: 700;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-info {
    background: #e0f2fe;
    color: #075985;
}

.alert-info form {
    margin-top: 10px;
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    height: 2px;
    margin: 5px 0;
    background: var(--text);
}

.mobile-overlay {
    display: none;
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        width: min(var(--sidebar-width), 86vw);
        transform: translateX(-100%);
        transition: transform 180ms ease;
        box-shadow: var(--shadow);
    }

    body.menu-open .sidebar {
        transform: translateX(0);
    }

    .menu-toggle {
        display: block;
        flex: 0 0 auto;
    }

    .mobile-overlay {
        position: fixed;
        inset: 0;
        z-index: 30;
        background: rgba(15, 23, 42, 0.42);
    }

    body.menu-open .mobile-overlay {
        display: block;
    }

    .topbar {
        min-height: 68px;
        padding: 12px 16px;
    }

    .logout-form span {
        display: none;
    }

    .notification-menu {
        margin-left: auto;
    }

    .notification-panel {
        position: fixed;
        top: 62px;
        right: 12px;
        left: 12px;
        width: auto;
        max-height: calc(100vh - 84px);
    }

    .topbar h1 {
        font-size: 20px;
    }

    .content {
        padding: 16px;
    }

    .panel {
        padding: 16px;
    }

    .panel-header,
    .split-panel {
        display: grid;
        grid-template-columns: 1fr;
    }

    .form-grid,
    .permission-grid {
        grid-template-columns: 1fr;
    }

    .primary-button,
    .secondary-button,
    .form-actions .primary-button {
        width: 100%;
    }

    .data-table {
        min-width: 0;
    }

    .data-table thead {
        display: none;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        padding: 12px 0;
        border-bottom: 1px solid var(--line);
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        gap: 14px;
        padding: 8px 0;
        border-bottom: 0;
    }

    .data-table td::before {
        content: attr(data-label);
        flex: 0 0 42%;
        color: var(--muted);
        font-weight: 700;
    }

    .data-table td.actions {
        justify-content: flex-start;
        gap: 8px;
    }

    .data-table td.actions::before {
        content: "";
        display: none;
    }

    .actions a,
    .actions button {
        min-height: 40px;
        border: 1px solid var(--line);
        border-radius: 8px;
    }

    .workflow-board,
    .task-meta {
        grid-template-columns: 1fr;
    }

    .task-card header,
    .revision-card header,
    .task-actions div {
        display: grid;
    }

    .task-actions .primary-button,
    .task-actions .secondary-button,
    .task-actions .danger-button {
        width: 100%;
    }

    .empty-state {
        min-height: calc(100vh - 100px);
        padding: 24px 18px;
    }
}

@media (max-width: 520px) {
    .topbar-kicker {
        display: none;
    }

    .empty-state h2 {
        font-size: 22px;
    }

    .empty-state p {
        font-size: 15px;
    }
}
