:root {
    --bg: #f3f6fb;
    --bg-deep: #e8eef6;
    --surface: #ffffff;
    --surface2: #f8fafc;
    --surface3: #eef4fa;
    --border: #d8e1ec;
    --border-strong: #b8c7d9;
    --accent: #185abd;
    --accent-strong: #13479a;
    --accent-soft: #eaf2ff;
    --text: #1f2937;
    --text-strong: #0f172a;
    --text-muted: #66758a;
    --success: #15803d;
    --warning: #b7791f;
    --danger: #c2410c;
    --font: "Sarabun", "Noto Sans Thai", "Leelawadee UI", "Segoe UI", sans-serif;
    --mono: "Consolas", "IBM Plex Mono", "SFMono-Regular", monospace;
    --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.06);
    --shadow: 0 20px 44px rgba(15, 23, 42, 0.08);
}

html {
    color-scheme: light;
}

body,
input,
select,
textarea,
button {
    font-family: var(--font);
}

body {
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.96), transparent 28%),
        linear-gradient(180deg, #f7f9fc 0%, var(--bg) 42%, var(--bg-deep) 100%);
    color: var(--text);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 8% 0%, rgba(24, 90, 189, 0.08), transparent 22%),
        radial-gradient(circle at 100% 10%, rgba(14, 116, 144, 0.06), transparent 18%);
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.26;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.22) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px);
    background-size: 160px 160px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.22), transparent 60%);
}

.container {
    position: relative;
    z-index: 1;
    padding-top: 1.8rem;
}

.topbar {
    background:
        linear-gradient(90deg, rgba(15, 23, 42, 0.98) 0%, rgba(22, 36, 61, 0.98) 56%, rgba(24, 90, 189, 0.93) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(12px);
}

.topbar .logo-text {
    color: #ffffff;
    letter-spacing: 0.01em;
}

.topbar .logo-sub {
    color: rgba(223, 232, 245, 0.84);
}

.logo-icon {
    background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
}

.page-head {
    position: relative;
    margin-bottom: 1.25rem;
    padding: 1.45rem 1.55rem;
    border: 1px solid rgba(216, 225, 236, 0.98);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(248, 250, 252, 0.97));
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.page-head::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, var(--accent), #0ea5e9);
}

.page-head::after {
    content: "";
    position: absolute;
    right: -36px;
    top: -42px;
    width: 190px;
    height: 190px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(24, 90, 189, 0.12) 0%, rgba(24, 90, 189, 0) 70%);
}

.page-head h1,
.table-title,
.card-title,
.logo-text {
    color: var(--text-strong);
}

.page-head h1 {
    font-size: 1.7rem;
    line-height: 1.08;
    margin-bottom: 0.34rem;
}

.page-head p,
.logo-sub,
.table-meta,
.kpi-sub,
.kpi-label,
.field label,
.info-label {
    color: var(--text-muted);
}

.page-head p {
    max-width: 760px;
    font-size: 0.93rem;
}

.page-actions {
    align-items: center;
    gap: 0.75rem;
}

.auth-user-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.auth-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    min-height: 40px;
    padding: 0.42rem 0.82rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(202, 213, 226, 0.98);
    color: var(--text-strong);
    font-size: 0.78rem;
    font-weight: 700;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}

.auth-user-chip small {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.auth-role-chip {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0.34rem 0.74rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.auth-role-chip-lead {
    background: rgba(24, 90, 189, 0.10);
    color: var(--accent-strong);
    border-color: rgba(24, 90, 189, 0.16);
}

.auth-role-chip-member {
    background: rgba(15, 23, 42, 0.06);
    color: var(--text);
    border-color: rgba(207, 218, 231, 0.98);
}

.auth-logout-form {
    display: inline-flex;
    margin: 0;
}

.kpi-label,
.field label,
.info-label,
th {
    text-transform: none;
    letter-spacing: 0.01em;
}

.btn {
    background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
    border-color: rgba(24, 90, 189, 0.12);
    box-shadow: 0 12px 24px rgba(24, 90, 189, 0.18);
    padding: 0.68rem 1.16rem;
    border-radius: 10px;
    font-weight: 700;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(24, 90, 189, 0.22);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.98);
    color: var(--text-strong);
    border: 1px solid rgba(202, 213, 226, 0.98);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}

.btn-ghost:hover {
    background: #ffffff;
    border-color: rgba(184, 199, 217, 0.98);
}

.alert.ok {
    background: rgba(21, 128, 61, 0.12);
    color: #166534;
    border-color: rgba(21, 128, 61, 0.16);
}

.alert.warn {
    background: rgba(183, 121, 31, 0.12);
    color: #8a5a17;
    border-color: rgba(183, 121, 31, 0.18);
}

.alert.error {
    background: rgba(194, 65, 12, 0.12);
    color: #9a3412;
    border-color: rgba(194, 65, 12, 0.18);
}

.kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
}

.kpi-card,
.filter-card,
.table-card,
.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(248, 250, 252, 0.98));
    border-color: rgba(216, 225, 236, 0.98);
    box-shadow: var(--shadow);
}

.kpi-card,
.card {
    backdrop-filter: blur(8px);
}

.kpi-card {
    border-top-width: 4px;
    overflow: hidden;
}

.kpi-card::after {
    content: "";
    position: absolute;
    right: -24px;
    bottom: -42px;
    width: 128px;
    height: 128px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(24, 90, 189, 0.10) 0%, rgba(24, 90, 189, 0) 72%);
}

.kpi-value {
    color: var(--text-strong);
    font-size: 2rem;
}

.kpi-icon {
    opacity: 0.18;
}

.status-distribution {
    height: 8px;
    background: rgba(213, 223, 235, 0.92);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.8);
}

.filter-card,
.table-card,
.card {
    overflow: hidden;
}

.table-head,
.card-header {
    background: linear-gradient(135deg, rgba(24, 90, 189, 0.07), rgba(14, 116, 144, 0.08));
    border-bottom-color: rgba(216, 225, 236, 0.98);
}

.field input,
.field select,
.field textarea,
.detail-block,
.history-item,
.muted-box,
th,
.page-btn {
    background: rgba(255, 255, 255, 0.98);
}

.field input,
.field select,
.field textarea {
    color: var(--text-strong);
    border-color: rgba(210, 219, 230, 0.98);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.field input::placeholder,
.field textarea::placeholder {
    color: #92a0b2;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: rgba(24, 90, 189, 0.42);
    box-shadow: 0 0 0 3px rgba(24, 90, 189, 0.10);
}

th {
    background: #f0f5fb;
    color: #64748b;
    border-bottom-color: rgba(216, 225, 236, 0.98);
}

td {
    color: var(--text);
    border-bottom-color: rgba(226, 233, 241, 0.98);
}

tr:hover td {
    background: rgba(234, 242, 255, 0.62);
}

.account-code,
.history-date {
    color: var(--accent-strong);
    font-weight: 600;
}

.shop-name {
    color: var(--text-strong);
}

.detail-cell,
.phone-cell,
.date-cell,
.shop-name small,
.muted-box,
.pagination-info {
    color: #66768a;
}

.detail-cell {
    min-width: 320px;
}

.detail-card {
    padding: 0.78rem 0.84rem;
    border-radius: 14px;
    border: 1px solid rgba(199, 212, 228, 0.98);
    background: linear-gradient(180deg, #ffffff 0%, #f4f8fd 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.detail-kicker {
    font-size: 0.66rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.03em;
    margin-bottom: 0.34rem;
}

.detail-title {
    color: var(--text-strong);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.45;
}

.detail-note {
    margin-top: 0.3rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.55;
}

.contact-cell,
.officer-cell {
    color: var(--text);
    font-weight: 600;
}

.badge {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.actions-cell {
    width: 164px;
}

.action-stack {
    display: grid;
    gap: 0.54rem;
    min-width: 132px;
}

.table-action {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0.64rem 0.84rem;
    border-radius: 11px;
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.14s ease;
}

.table-action:hover {
    transform: translateY(-1px);
}

.table-action-primary {
    background: linear-gradient(135deg, rgba(24, 90, 189, 0.10), rgba(37, 99, 235, 0.04));
    border-color: rgba(24, 90, 189, 0.18);
    color: var(--accent-strong);
    box-shadow: 0 8px 18px rgba(24, 90, 189, 0.08);
}

.table-action-secondary {
    background: rgba(15, 23, 42, 0.03);
    border-color: rgba(207, 218, 231, 0.98);
    color: var(--text);
}

.page-btn {
    border-color: rgba(207, 218, 231, 0.98);
    color: #64748b;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.04);
}

.page-btn.active {
    background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
    border-color: rgba(24, 90, 189, 0.16);
    color: #ffffff;
}

.quality-banner,
.duplicate-alert {
    margin-bottom: 1rem;
    padding: 1.1rem 1.2rem;
    border-radius: 16px;
    border: 1px solid rgba(191, 149, 80, 0.24);
    background: linear-gradient(135deg, rgba(255, 248, 236, 0.98), rgba(255, 255, 255, 0.97));
    box-shadow: 0 14px 30px rgba(120, 86, 28, 0.08);
}

.quality-title,
.duplicate-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: #8a5a17;
}

.quality-copy,
.duplicate-copy {
    margin-top: 0.24rem;
    font-size: 0.87rem;
    color: #94642a;
}

.quality-list,
.duplicate-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 0.78rem;
}

.quality-pill,
.duplicate-link {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    padding: 0.48rem 0.72rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(202, 175, 131, 0.24);
    color: #7c531a;
    font-size: 0.79rem;
    text-decoration: none;
}

.quality-pill strong,
.duplicate-link strong {
    color: #5d3d17;
}

.row-duplicate td {
    background-image: linear-gradient(90deg, rgba(255, 237, 213, 0.48), transparent 58%);
}

.row-hint {
    margin-top: 0.32rem;
    font-size: 0.73rem;
    color: #986225;
}

.inline-hint {
    margin-top: 0.4rem;
    font-size: 0.77rem;
    color: #8a632b;
}

.detail-block,
.history-item {
    border-color: rgba(216, 225, 236, 0.98);
}

.detail-block {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(242, 246, 251, 0.97));
}

.empty-state .icon {
    opacity: 0.52;
}

@media (max-width: 700px) {
    .container {
        padding-top: 1.15rem;
    }

    .page-head {
        padding: 1.15rem 1.08rem;
    }

    .page-head h1 {
        font-size: 1.45rem;
    }

    .quality-list,
    .duplicate-links {
        display: grid;
    }
}
