:root {
    --brand-primary: #03264A;
    --brand-secondary: #82C473;
    --brand-accent-blue: #17C2C9;
    --brand-accent-blue-rgb: 23, 194, 201;
    --brand-accent-orange: #F15A29;
    --gray-dark: #5A5A5A;
    --gray-mid: #9B9B9B;
    --main-bg: #f2f5f9;
    --sidebar-bg: #f7f8fb;
    --sidebar-border: #dde3ea;
    --panel-bg: #ffffff;
    --line: #dbe3ec;
    --line-strong: #c9d4df;
    --text: #03264A;
    --muted: #5b6f88;
    --accent: var(--brand-accent-blue);
    --accent-deep: #03264A;
    --accent-soft: rgba(var(--brand-accent-blue-rgb), 0.14);
    --shadow: 0 10px 30px rgba(21, 34, 50, 0.08);
    --radius: 14px;
    --sidebar-width: 190px;
    --header-height: 66px;
    --row-h: 38px;
    --resource-role-col-width: 320px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: Inter, Arial, Helvetica, sans-serif;
    background: var(--main-bg);
    color: var(--text);
}

input[type='text'],
input[type='search'],
input[type='number'],
input[type='email'],
input[type='password'],
input[type='date'],
input[type='month'],
input[type='tel'],
input[type='url'],
select,
textarea {
    border-color: var(--gray-mid);
    color: var(--brand-primary);
    transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

input[type='text']:hover,
input[type='search']:hover,
input[type='number']:hover,
input[type='email']:hover,
input[type='password']:hover,
input[type='date']:hover,
input[type='month']:hover,
input[type='tel']:hover,
input[type='url']:hover,
select:hover,
textarea:hover {
    border-color: var(--brand-accent-blue);
    background: #eef6ff;
}

input[type='text']:focus,
input[type='search']:focus,
input[type='number']:focus,
input[type='email']:focus,
input[type='password']:focus,
input[type='date']:focus,
input[type='month']:focus,
input[type='tel']:focus,
input[type='url']:focus,
select:focus,
textarea:focus {
    border-color: var(--brand-accent-blue);
    box-shadow: 0 0 0 3px rgba(var(--brand-accent-blue-rgb), 0.14);
    outline: none;
}

input[type='checkbox'],
input[type='radio'] {
    accent-color: var(--brand-accent-blue);
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1400;
}

.sidebar-top {
    padding: 18px 18px 12px;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.brand-logo {
    max-width: 133px;
    width: 100%;
    height: auto;
}

.brand-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon {
    height: 23px;
    width: auto;
    flex: 0 0 auto;
}

.brand-name {
    display: block;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.3px;
}

.nav {
    padding: 10px 12px 18px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}


.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    color: #4f5663;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
}

.nav-item:hover {
    background: #edf1f6;
    color: var(--text);
}

.nav-item.active {
    background: transparent;
    color: var(--accent-deep);
    font-weight: 800;
}

.nav-icon {
    width: 18px;
    text-align: center;
    opacity: .8;
}

.sub-nav {
    margin: 0 0 8px 44px;
    display: grid;
    gap: 2px;
}

.sub-nav-item {
    display: block;
    border-radius: 8px;
    padding: 7px 10px;
    color: #64748b;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.sub-nav-item:hover {
    background: #edf1f6;
    color: var(--text);
}

.sub-nav-item.active {
    background: transparent;
    color: var(--accent-deep);
    font-weight: 800;
}


.sidebar-bottom {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid var(--sidebar-border);
}

.profile-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 8px 10px;
    color: var(--text);
    cursor: pointer;
}

.profile-trigger:hover,
.profile-trigger.open {
    background: #edf1f6;
    border-color: #e0e7ef;
}

.avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    flex: 0 0 30px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--brand-accent-blue), #0c6a94 52%, #03264A);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    overflow: hidden;
}

.avatar-photo {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: 999px;
}

.profile-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    line-height: 1.15;
    text-align: left;
}

.profile-name {
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.profile-menu {
    display: none;
    position: absolute;
    left: calc(var(--sidebar-width) + 12px);
    bottom: 18px;
    width: 224px;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 8px;
    z-index: 1500;
}

.profile-menu.open {
    display: block;
}

.profile-menu a,
.profile-menu button {
    width: 100%;
    display: flex;
    align-items: center;
    text-align: left;
    background: transparent;
    border: 0;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #4f5663;
    text-decoration: none;
    cursor: pointer;
}

.profile-menu a:hover,
.profile-menu button:hover {
    background: #edf1f6;
    color: var(--text);
}

.profile-divider {
    height: 1px;
    background: var(--line);
    margin: 8px 0;
}

.profile-email {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.main {
    margin-left: var(--sidebar-width);
    min-width: 0;
    flex: 1;
    background: var(--main-bg);
}

.topbar {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(255, 255, 255, .85);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(8px);
}

.page-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.3px;
    color: var(--brand-primary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn,
.btn-secondary,
.btn-secondary-blue {
    height: 36px;
    border-radius: 10px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.btn {
    border: 1px solid var(--brand-primary);
    color: #fff;
    background: var(--brand-primary);
    opacity: 0.85;
    transition: opacity 120ms ease;
}

.btn:hover {
    opacity: 1;
}

.btn-secondary {
    border: 1px solid #b7dcb0;
    background: #fff;
    color: var(--brand-primary);
    transition: background-color 120ms ease, border-color 120ms ease;
}

.btn-secondary:hover {
    background: #f6fcf8;
}

.btn-secondary-blue {
    border: 1px solid var(--brand-accent-blue);
    background: #fff;
    color: var(--brand-primary);
    transition: background-color 120ms ease, border-color 120ms ease;
}

.btn-secondary-blue:hover {
    background: #eef6ff;
    border-color: var(--brand-accent-blue);
}

.json-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2200;
    background: rgba(8, 18, 28, 0.58);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.json-modal-overlay[hidden] {
    display: none !important;
}

.json-modal {
    width: min(960px, 100%);
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--line-strong);
    box-shadow: 0 18px 40px rgba(3, 38, 74, 0.28);
    padding: 14px;
}

.json-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.json-modal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--brand-primary);
}

.json-modal-close {
    height: 30px;
    border-radius: 8px;
    border: 1px solid #d6e1ec;
    background: #fff;
    color: #304154;
    font-size: 12px;
    font-weight: 700;
    padding: 0 10px;
    cursor: pointer;
}

.json-modal-close:hover {
    background: #f4f8fb;
}

.json-copy-note {
    font-size: 12px;
    color: #637487;
    margin-bottom: 8px;
    font-weight: 600;
}

.json-copy-note.is-success {
    color: #15803d;
}

.json-modal-content {
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f7fafc;
    color: #1f2d3d;
    padding: 12px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.45;
    max-height: 68vh;
    overflow-y: auto;
    white-space: pre;
    cursor: copy;
}

.content {
    padding: 24px;
}

.session-expiry-banner {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 2300;
    width: min(760px, calc(100vw - 24px));
    border: 1px solid var(--brand-accent-orange);
    border-radius: 12px;
    background: #fff3eb;
    box-shadow: 0 14px 30px rgba(3, 38, 74, 0.16);
    padding: 12px 14px;
}

.session-expiry-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.session-expiry-copy {
    color: #5f4023;
    font-size: 13px;
    line-height: 1.35;
}

.session-expiry-copy strong {
    color: #8a4b00;
}

.session-expiry-countdown {
    display: inline-block;
    min-width: 124px;
    font-weight: 700;
    color: #7a3f00;
}

.session-expiry-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.session-expiry-actions .session-expiry-dismiss {
    border-color: var(--brand-accent-blue);
    background: #ffffff;
}

.session-expiry-actions .session-expiry-dismiss:hover {
    background: #eef6ff;
    border-color: var(--brand-accent-blue);
}

@media (max-width: 720px) {
    .session-expiry-banner {
        bottom: 10px;
        width: calc(100vw - 16px);
        padding: 10px;
    }

    .session-expiry-content {
        flex-direction: column;
        align-items: stretch;
    }

    .session-expiry-actions {
        justify-content: flex-end;
    }
}


body.dark-theme {
    --main-bg: #0B1220;
    --sidebar-bg: #111B2E;
    --sidebar-border: #2E405D;
    --panel-bg: #111B2E;
    --tr-bg: #111B2E;
    --gray-mid: #2E405D;
    --line: #2E405D;
    --line-strong: #3b4f70;
    --text: #E8EDF5;
    --muted: #a8b5c8;
    --accent-deep: #E8EDF5;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    background: var(--main-bg);
    color: var(--text);
}

body.dark-theme .main {
    background: var(--main-bg);
}

body.dark-theme .sidebar {
    background: var(--sidebar-bg);
    border-color: var(--sidebar-border);
}

body.dark-theme .profile-menu,
body.dark-theme .json-modal,
body.dark-theme .content-card,
body.dark-theme .panel,
body.dark-theme .card,
body.dark-theme .table-wrap,
body.dark-theme table,
body.dark-theme .admin-panel,
body.dark-theme .overview-card,
body.dark-theme .project-card,
body.dark-theme .fee-card {
    background: var(--panel-bg);
    color: var(--text);
    border-color: var(--gray-mid);
}

body.dark-theme .topbar {
    background: rgba(17, 27, 46, 0.9);
}

body.dark-theme .page-title,
body.dark-theme h1,
body.dark-theme h2,
body.dark-theme h3,
body.dark-theme h4,
body.dark-theme label,
body.dark-theme th,
body.dark-theme td,
body.dark-theme .profile-name,
body.dark-theme .json-modal-title {
    color: var(--text);
}

body.dark-theme .nav-item,
body.dark-theme .sub-nav-item,
body.dark-theme .profile-menu a,
body.dark-theme .profile-menu button,
body.dark-theme .profile-email,
body.dark-theme .json-copy-note {
    color: var(--muted);
}

body.dark-theme .nav-item:hover,
body.dark-theme .nav-item.active,
body.dark-theme .sub-nav-item:hover,
body.dark-theme .sub-nav-item.active,
body.dark-theme .profile-trigger:hover,
body.dark-theme .profile-trigger.open,
body.dark-theme .profile-menu a:hover,
body.dark-theme .profile-menu button:hover {
    background: #1A2942;
    color: var(--text);
    border-color: var(--gray-mid);
}

body.dark-theme input[type='text'],
body.dark-theme input[type='search'],
body.dark-theme input[type='number'],
body.dark-theme input[type='email'],
body.dark-theme input[type='password'],
body.dark-theme input[type='date'],
body.dark-theme input[type='month'],
body.dark-theme input[type='tel'],
body.dark-theme input[type='url'],
body.dark-theme select,
body.dark-theme textarea,
body.dark-theme .custom-dd-toggle,
body.dark-theme .custom-dd-menu,
body.dark-theme .json-modal-content {
    background: #0B1220;
    border-color: var(--gray-mid);
    color: var(--text);
}

body.dark-theme input:hover,
body.dark-theme select:hover,
body.dark-theme textarea:hover,
body.dark-theme input:focus,
body.dark-theme select:focus,
body.dark-theme textarea:focus {
    background: #1A2942;
}

body.dark-theme thead th,
body.dark-theme .table-header,
body.dark-theme .summary-header {
    background: var(--gray-mid);
    color: var(--text);
    border-color: var(--gray-mid);
}

body.dark-theme tr,
body.dark-theme td,
body.dark-theme th,
body.dark-theme .profile-divider {
    border-color: var(--gray-mid);
}

body.dark-theme tbody tr {
    background: #373D49;
}

body.dark-theme .readonly-cell {
    color: var(--text);
}

body.dark-theme .btn-secondary,
body.dark-theme .btn-secondary-blue {
    background: #1A2942;
    border-color: var(--gray-mid);
    color: var(--text);
}

body.dark-theme .planned-fee-under-budget {
    color: #3DDC84 !important;
}

body.dark-theme .planned-fee-over-budget {
    color: #FF5C5C !important;
}

.theme-toggle-btn {
    gap: 10px;
    justify-content: flex-start !important;
}

.theme-toggle-btn:disabled {
    cursor: wait;
    opacity: 0.7;
}

.theme-toggle-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 18px;
}

.theme-toggle-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}
