:root {
    --navy: #0A1F44;
    --navy-dark: #07162f;
    --gold: #C6A75E;
    --gold-hover: #b39248;
    --gold-soft: #f7f1e4;
    --teal: #C6A75E;
    --teal-soft: #f7f1e4;
    --paper: #f5f6f8;
    --card: #ffffff;
    --text: #0A1F44;
    --muted: #6b7c88;
    --line: #e2e6ee;
    --danger: #c44536;
    --warn: #d0892a;
}

html, body { min-height: 100%; }
body.app-body {
    font-family: "Sarabun", "Noto Sans Thai", sans-serif;
    background: var(--paper);
    color: var(--text);
}

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at top right, rgba(198,167,94,.22), transparent 42%),
        linear-gradient(160deg, #07162f 0%, #0A1F44 55%, #1a335c 140%);
}
.auth-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 18px;
    padding: 32px 28px;
    box-shadow: 0 20px 50px rgba(0,0,0,.18);
}
.auth-card-wide { max-width: 640px; }
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: var(--muted);
    font-size: .85rem;
}
.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}
.btn-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--navy);
    font-weight: 600;
}
.btn-google:hover {
    background: #f8f9fb;
    border-color: var(--gold);
    color: var(--navy);
}
.brand-logo {
    display: block;
    max-width: 240px;
    height: auto;
    margin-bottom: 8px;
}
.sidebar .brand {
    display: block;
    background: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 20px;
    text-align: center;
    text-decoration: none;
}
.sidebar .brand img {
    max-width: 100%;
    height: auto;
    max-height: 52px;
}
.lang-switch a { color: var(--muted); text-decoration: none; font-size: .9rem; }
.lang-switch a.active { color: var(--gold); font-weight: 700; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px;
    background: var(--navy);
    color: #d7e0ee;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar a {
    display: flex; align-items: center; justify-content: space-between;
    color: #d7e0ee; text-decoration: none;
    padding: 10px 12px; border-radius: 10px; margin-bottom: 4px;
}
.sidebar a:hover, .sidebar a.active { background: rgba(198,167,94,.18); color: #fff; }
.sidebar a.brand:hover, .sidebar a.brand.active { background: #fff; }
.main { flex: 1; min-width: 0; }
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.content { padding: 20px; padding-bottom: 88px; }
.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    height: 100%;
}
.stat-card .label { color: var(--muted); font-size: .85rem; }
.stat-card .value { font-size: 1.8rem; font-weight: 700; color: var(--navy); }
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
}
.badge-status { font-weight: 600; }
.badge-uploaded, .badge-pending { background: #eef2f5; color: #3d5160; }
.badge-under_review, .badge-preparing, .badge-filed { background: #fff4de; color: #8a5a12; }
.badge-approved { background: var(--gold-soft); color: #8a6d2e; }
.badge-rejected { background: #fde8e6; color: var(--danger); }
.badge-need_info, .badge-waiting_ack { background: #e8f0ff; color: #274b8a; }
.badge-completed { background: #e5f8ef; color: #1b6b43; }
.quick-link {
    display: block; background: #fff; border: 1px solid var(--line);
    border-radius: 14px; padding: 16px; text-decoration: none; color: var(--text);
}
.quick-link:hover { border-color: var(--gold); color: var(--navy); }
.chat-box { height: 52vh; overflow-y: auto; background: #f8f7f3; border-radius: 0; padding: 16px; border: 0; }
.bubble { max-width: 80%; padding: 10px 14px; border-radius: 16px; margin-bottom: 10px; }
.bubble.me { background: var(--navy); color: #fff; margin-left: auto; }
.bubble.them { background: #fff; border: 1px solid var(--line); }
.chat-shell {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
}
.chat-composer {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 12px;
    border-top: 1px solid var(--line);
    background: #fff;
}
.chat-composer textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    resize: none;
}
.chat-attach {
    position: relative;
    display: inline-flex;
    align-items: center;
    max-width: 140px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: .85rem;
    color: var(--navy);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-attach input { display: none; }
.chat-list-item, .notify-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: var(--text);
}
.chat-list-item:hover, .notify-item:hover { background: #fbfaf7; }
.chat-list-item.is-unread, .notify-item.is-unread { background: var(--gold-soft); }
.notify-item { margin: 0; }
.notify-body {
    flex: 1;
    text-align: left;
    background: none;
    border: 0;
    padding: 0;
    color: inherit;
}
.min-width-0 { min-width: 0; }
.bottom-nav {
    display: none;
    position: fixed; left: 0; right: 0; bottom: 0;
    background: #fff; border-top: 1px solid var(--line);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    z-index: 20;
}
.bottom-nav a { flex: 1; text-align: center; font-size: .75rem; color: var(--muted); text-decoration: none; }
.bottom-nav a.active { color: var(--gold); font-weight: 700; }
.table td, .table th { vertical-align: middle; }
.btn-teal { background: var(--gold); border-color: var(--gold); color: var(--navy); font-weight: 600; }
.btn-teal:hover { background: var(--gold-hover); border-color: var(--gold-hover); color: var(--navy); }
.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-navy:hover { color: #fff; background: var(--navy-dark); }
.btn-outline-navy {
    border-color: var(--navy);
    color: var(--navy);
    font-weight: 600;
}
.btn-outline-navy:hover { background: var(--navy); color: #fff; }
.btn-outline-light { font-weight: 600; }

.toolbar {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    overflow-x: auto;
}
.toolbar-search {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 360px;
}
.toolbar .btn {
    flex-shrink: 0;
    white-space: nowrap;
}
.toolbar .ms-auto { margin-left: auto !important; }

.people-table thead th {
    background: #f8f6f1;
    color: var(--navy);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.people-table tbody tr:hover { background: #fbfaf7; }
.person-cell { display: flex; align-items: center; gap: 12px; }
.person-avatar {
    width: 40px; height: 40px; border-radius: 12px;
    background: var(--gold-soft); color: var(--navy);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; flex-shrink: 0;
}
.person-avatar.lg { width: 64px; height: 64px; font-size: 1.3rem; border-radius: 18px; }
.chip {
    display: inline-block;
    background: var(--gold-soft);
    color: var(--navy);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: .8rem;
    font-weight: 600;
    margin: 0 4px 4px 0;
}
.count-pill {
    display: inline-flex; min-width: 32px; justify-content: center;
    background: #eef2f6; color: var(--navy); border-radius: 999px; padding: 2px 10px; font-weight: 700;
}
.form-check-input.status-switch {
    width: 2.4em; height: 1.25em; cursor: pointer;
    background-color: #c5ced6; border: 0;
}
.form-check-input.status-switch:checked {
    background-color: #1b6b43;
}
.profile-hero {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.info-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    height: 100%;
}
.info-card .label { color: var(--muted); font-size: .8rem; margin-bottom: 4px; }
.info-card .value { font-weight: 700; color: var(--navy); word-break: break-word; }
.panel-title { font-weight: 700; color: var(--navy); margin-bottom: 14px; }
.file-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.file-row:last-child { border-bottom: 0; }
.ts-wrapper .ts-control {
    border-radius: 10px;
    border-color: var(--line);
    min-height: 42px;
    padding: 6px 10px;
}
.ts-wrapper.focus .ts-control { border-color: var(--gold); box-shadow: 0 0 0 .2rem rgba(198,167,94,.2); }
.ts-dropdown .active { background: var(--gold-soft); color: var(--navy); }

.welcome-modal { border-radius: 18px; }
.welcome-steps, .help-steps { padding-left: 1.2rem; margin-bottom: 0; }
.welcome-steps li, .help-steps li { margin-bottom: 8px; }
.rating-row { display: flex; gap: 8px; flex-wrap: wrap; }
.rating-option { cursor: pointer; }
.rating-option input { display: none; }
.rating-option span {
    display: inline-flex;
    width: 40px; height: 40px;
    align-items: center; justify-content: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-weight: 700;
    color: var(--navy);
}
.secure-note {
    margin-top: 12px;
    background: #eef6f1;
    border: 1px solid #cfe4d6;
    color: #1b6b43;
    border-radius: 12px;
    padding: 12px 14px;
    font-weight: 600;
}
.upload-rules { margin-top: 8px; color: var(--navy); }
.upload-rules.small { color: var(--muted); }

@media (max-width: 991px) {
    .sidebar { display: none; }
    .bottom-nav { display: flex; }
    .content { padding: 16px 12px 96px; }
}
