@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

/* ═══════════ Yulgang GM — Jade light theme (ให้เข้าชุดกับ finance.php) ═══════════
   คงชื่อ class เดิมทั้งหมด (dashboard-shell / sidebar / card / stat / btn / table / modal / auth-card)
   เปลี่ยนเฉพาะโทนสี ฟอนต์ และระยะ — ทุกหน้าที่ลิงก์ styles.css เปลี่ยนตามทันที
   ธีมมืดเดิมสำรองไว้ที่ /root/bak_scene/styles.css.bak_dark_* */
:root {
    --bg-main: #f4f6f8;
    --bg-card: #ffffff;
    --bg-card-solid: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-input: #ffffff;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --primary: #0f766e;
    --primary-hover: #0b5f59;
    --primary-soft: #e6f4f2;
    --primary-glow: rgba(15, 118, 110, 0.18);
    --gold: #b45309;
    --gold-soft: #fffbeb;
    --danger: #b91c1c;
    --danger-hover: #991b1b;
    --danger-soft: #fef2f2;
    --success: #047857;
    --success-soft: #ecfdf5;
    --blue: #1d4ed8;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-pop: 0 20px 48px rgba(16, 24, 40, 0.18);
    --ring: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body, input, button, select, textarea, table, h1, h2, h3, h4, h5, h6 {
    font-family: 'Noto Sans Thai', 'Inter', -apple-system, 'Segoe UI', Tahoma, sans-serif !important;
}

body {
    background: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(15, 118, 110, 0.18); }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 8px;
    border: 2px solid var(--bg-main);
}
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

.dashboard-shell { display: flex; min-height: 100vh; width: 100%; }

/* ═══ Sidebar ═══ */
.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}

.sidebar-brand {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-user {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.5;
}

.sidebar-menu { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 9px 12px;
    color: #374151;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}

.sidebar-link:hover { background: #f3f4f6; color: var(--text-main); }

.sidebar-link.is-active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* ═══ Main ═══ */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 24px 28px 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* ═══ Cards ═══ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header h3 { font-size: 1rem; font-weight: 600; }

.card-header .title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.page-header .title { font-size: 1.35rem; }

.card-header .sub { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 18px; }

/* ═══ Grid ═══ */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .main-content { padding: 16px 12px 32px; }
}

/* ═══ Stats (แบบ tile ของหน้าการเงิน: แถบสีซ้าย) ═══ */
.stat {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform .15s ease, box-shadow .15s ease;
}

.stat:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16, 24, 40, 0.08); }

.stat-soft { border-left-color: var(--gold); }

.grid-4 .stat:nth-child(2) { border-left-color: var(--blue); }
.grid-4 .stat:nth-child(3) { border-left-color: #7c3aed; }
.grid-4 .stat:nth-child(4) { border-left-color: var(--gold); }

.stat .k {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stat .v {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

/* ═══ Buttons ═══ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    color: #374151;
    transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
    user-select: none;
}

.btn:hover { background: #f3f4f6; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-ghost {
    background: #fff;
    border-color: var(--border);
    color: #374151;
}
.btn-ghost:hover {
    background: var(--primary-soft);
    border-color: rgba(15, 118, 110, 0.35);
    color: var(--primary);
}

.btn-danger {
    background: var(--danger-soft);
    border-color: #fecaca;
    color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-discord {
    background: #5865F2;
    border-color: #5865F2;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(88, 101, 242, 0.28);
}
.btn-discord:hover { background: #4752c4; border-color: #4752c4; color: #fff; box-shadow: 0 6px 18px rgba(88, 101, 242, 0.38); }
.auth-help { text-align: center; font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* ═══ Forms ═══ */
input, select, textarea, .players-search-input {
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 8px 10px;
    font-size: 0.9rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}

input::placeholder, textarea::placeholder { color: #9ca3af; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
}

input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }

label { color: var(--text-muted); font-size: 0.85rem; }

.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.players-search-form { gap: 8px; }
.players-search-input { min-width: 220px; }

/* ═══ Tables ═══ */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

th {
    text-align: left;
    padding: 8px 12px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    background: #f9fafb;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
}

td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    vertical-align: top;
}

tbody tr { transition: background .12s ease; }
tbody tr:hover td { background: #f9fafb; }
tbody tr:last-child td { border-bottom: none; }

a { color: var(--primary); }

/* ═══ Messages ═══ */
.msg {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    border: 1px solid;
}
.msg-ok {
    background: var(--success-soft);
    border-color: #a7f3d0;
    color: var(--success);
}
.msg-err {
    background: var(--danger-soft);
    border-color: #fecaca;
    color: var(--danger);
}

.muted { color: var(--text-muted); }
.is-hidden { display: none !important; }

/* ═══ Modal ═══ */
.modal-mask, .modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
    backdrop-filter: blur(2px);
    display: none;              /* ซ่อนก่อน — JS เติม .is-open ตอนเปิด */
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.modal-mask.is-open, .modal-backdrop.is-open,
.modal-mask.active, .modal-backdrop.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card, .modal-dialog {
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    padding: 22px;
    width: min(480px, 92vw);
    max-height: 86vh;
    overflow-y: auto;
    animation: modalIn .2s ease both;
}

.modal-card-wide { width: min(760px, 94vw); }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.field--full { grid-column: 1 / -1; }

/* ═══ Login pages ═══ */
.auth-wrap, .container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(900px 420px at 80% -10%, rgba(15, 118, 110, 0.10), transparent 60%),
        radial-gradient(700px 380px at -10% 110%, rgba(180, 83, 9, 0.07), transparent 55%),
        var(--bg-main);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 12px 36px rgba(16, 24, 40, 0.10);
    padding: 32px 30px;
    width: min(400px, 94vw);
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: modalIn .3s ease both;
}

.auth-card h1, .auth-card h2 {
    font-size: 1.35rem;
    color: var(--primary);
    text-align: center;
    margin-bottom: 6px;
}

.auth-card input { width: 100%; padding: 11px 14px; }
.auth-card button, .auth-card .btn { width: 100%; padding: 11px; font-size: 0.95rem; }

/* ความปลอดภัย: เนื้อหาหลักต้องมองเห็นเสมอ ห้ามให้อนิเมชันค้างจนจอว่าง */
.main-content, .card, .stat, .msg { opacity: 1 !important; animation: none !important; }

/* ═══ มือถือ: ซ้อนเมนูบน-เนื้อหาล่าง ═══ */
@media (max-width: 760px) {
    .dashboard-shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
    .sidebar-brand { font-size: 0.95rem; }
    .sidebar-menu { flex-direction: row; flex-wrap: wrap; gap: 6px; flex: none; }
    .sidebar-link { font-size: 0.82rem; padding: 7px 10px; white-space: nowrap; }
    .sidebar-actions { flex-direction: row; flex-wrap: wrap; gap: 6px; padding-top: 8px; border-top: 0; }
    .sidebar-actions .btn { padding: 7px 10px; font-size: 0.8rem; }
    .main-content { padding: 12px 12px 30px; gap: 12px; }
    .page-header .title { font-size: 1.1rem; }
    .stat .v { font-size: 1.25rem; }
}

/* ═══════════ Yulgang W — GM theme (matches yulgang-w.com) ═══════════
   Paper surfaces, lacquer-red primary, gold accents. Overrides the tokens above only;
   every page that links styles.css follows. */
:root {
    --bg-main: #f6eee2;
    --bg-card: #fffaf2;
    --bg-card-solid: #fffaf2;
    --bg-sidebar: #2a0b07;
    --bg-input: #ffffff;
    --border: #e4d3b8;
    --border-strong: #cfb48a;
    --text-main: #382c23;
    --text-muted: #8a7863;
    --primary: #941711;
    --primary-hover: #6e0f0a;
    --primary-soft: #f8e6dc;
    --primary-glow: rgba(148, 23, 17, 0.18);
    --gold: #a8741f;
    --gold-soft: #fbf1dc;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow-card: 0 2px 6px rgba(96, 65, 25, 0.08);
    --ring: 0 0 0 3px rgba(227, 169, 49, 0.28);
}
::selection { background: rgba(236, 208, 152, 0.55); }
body { background-image: radial-gradient(ellipse at top, #fffdf8, transparent 70%); background-attachment: fixed; }

/* sidebar: same lacquer band as the site header */
.sidebar { background: linear-gradient(180deg, #2a0b07, #4a150c); border-right: 1px solid #bd8b47; color: #f3dcc0; }
.sidebar a { color: #f3dcc0; }
.sidebar a:hover, .sidebar a.active { color: #ffd779; background: rgba(236, 208, 152, 0.10); }

.btn-primary { background: linear-gradient(#ad190c, #670800) !important; border-color: #d1a24c !important; color: #fff0c7 !important; }
.btn-primary:hover { background: linear-gradient(#c22a1a, #7c0d03) !important; }

/* login card */
.auth-card { border: 1px solid #d8c4a4; box-shadow: 0 15px 50px rgba(39, 18, 5, 0.18); }
.auth-card .card-header { background: linear-gradient(110deg, #260906, #51170e 60%, #260906); border-bottom: 2px solid #bd8b47; }
.auth-card .card-header .title { color: #f0d39b; }
.auth-card .card-header .sub { color: #e8cfae; }
.yw-brand { display: block; text-align: center; font: italic 700 30px/1 Georgia, serif; color: #f0d39b; text-shadow: 1px 2px #000; margin-bottom: 6px; }
.yw-brand b { font-size: 1.35em; color: #bc2418; }

.btn-discord { background: #06C755 !important; border-color: #06C755 !important; color: #fff !important; }
