:root {
    --page: var(--frame);
    --frame: #efefef;
    --surface: #ffffff;
    --soft: #efefef;          /* nền viên thuốc nav, nút tròn */
    --text: #051F20;
    --muted: #6b8178;
    --icon: #3f5b52;           /* icon / chữ nav chưa chọn */
    --border: #e4e4e7;
    --primary: #235347;
    --primary-text: #ffffff;
    --grad: linear-gradient(135deg, #235347, #163832);   /* nền nút, mục đang chọn */
    --grad-text: linear-gradient(90deg, #235347, #051F20); /* chữ logo */
    --accent: #235347;         /* chữ / viền nhấn */
    --tint: #DAF1DE;           /* nền nút phụ nhỏ */
    --tint-text: #163832;
    --ok: #235347; --err: #d83a3a;
    --radius: 22px;
    --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="dark"] {
    --page: var(--frame);
    --frame: #0e0e0f;
    --surface: #19191a;
    --soft: #242426;
    --text: #f1f1f2;
    --muted: #8b8b90;
    --icon: #a3a3a8;
    --border: #2a2a2d;
    --primary: #235347;
    --grad: linear-gradient(135deg, #235347, #163832);
    --grad-text: linear-gradient(90deg, #8EB69B, #DAF1DE);
    --accent: #8EB69B;
    --tint: #163832;
    --tint-text: #DAF1DE;
    --ok: #8EB69B;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 var(--font); background: var(--page); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
h1, h2 { margin: 0; }
code { background: var(--soft); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.muted { color: var(--muted); }
.ico { display: block; flex: none; }
.ico-text { font-size: 18px; line-height: 1; }
button { font-family: inherit; }

/* ===== Khung ngoài ===== */
.frame { max-width: 1560px; margin: 0 auto; background: transparent; padding: 20px 28px 32px; min-height: 100vh; }

/* ===== Header ===== */
.header { background: var(--surface); border-radius: 999px; height: 66px; padding: 0 20px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.header-left { display: flex; align-items: center; gap: 10px; }
.logo { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 700; font-size: 1.25rem; letter-spacing: -.01em; }
.logo-mark { width: 32px; height: 32px; color: var(--primary); }
.logo span, .auth-card h1 { background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.header-nav { display: flex; gap: 4px; background: var(--soft); border-radius: 999px; padding: 6px; }
.header-nav a { padding: 8px 20px; border-radius: 999px; font-weight: 500; font-size: .93rem; color: var(--icon); }
.header-nav a:hover { color: var(--text); }
.header-nav a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.header-right { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }

.round-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--soft); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.round-btn:hover { filter: brightness(.96); }
.menu-btn { display: none; }

.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--grad); color: var(--primary-text); display: grid; place-items: center; font-weight: 700; }
.dropdown { position: absolute; right: 0; top: calc(100% + 12px); min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.12); z-index: 30; }
.dropdown[hidden] { display: none; }
.dropdown-head { padding: 8px 12px; font-weight: 600; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown a, .dropdown button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: none; border-radius: 12px; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--soft); }

/* ===== Thân: sidebar + nội dung ===== */
.body { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 48px; margin-top: 40px; padding-left: 8px; align-items: start; }

.sidebar { position: sticky; top: 18px; display: flex; flex-direction: column; gap: 16px; min-height: calc(100vh - 170px); }
.side-group { background: var(--surface); border-radius: 999px; padding: 7px 6px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.side-bottom { margin-top: auto; }
.side-bottom form { margin: 0; }
.side-item { position: relative; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; border: 0; background: none; color: var(--icon); cursor: pointer; padding: 0; }
.side-item:hover { background: var(--soft); color: var(--text); }
.side-item.active { background: var(--grad); color: var(--primary-text); }
.side-item::after { content: attr(data-label); position: absolute; left: calc(100% + 14px); top: 50%; transform: translateY(-50%); background: var(--text); color: var(--surface); padding: 5px 10px; border-radius: 8px; font-size: .8rem; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 40; }
.side-item:hover::after { opacity: 1; }

.content { min-width: 0; }
.page-title { font-size: 2.1rem; font-weight: 500; letter-spacing: -.02em; margin-bottom: 22px; }
.page-title span { color: var(--muted); }

/* ===== Thành phần ===== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; }
.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 14px; }
.card h2 a { color: var(--text); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: .88rem; color: var(--muted); }
input, textarea, select { font: inherit; padding: 11px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--frame); color: var(--text); width: 100%; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn { background: var(--grad); color: var(--primary-text); border: 0; padding: 10px 20px; border-radius: 999px; font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn-sm { padding: 6px 14px; font-size: .85rem; }
.btn-ghost { background: var(--tint); color: var(--tint-text); }
.alert { padding: 11px 16px; border-radius: 14px; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--border); }
.alert-success { border-color: var(--ok); color: var(--ok); }
.alert-error { border-color: var(--err); color: var(--err); }

/* ===== Đăng nhập ===== */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 26px; padding: 32px; }
.auth-card h1 { font-size: 1.3rem; margin-bottom: 20px; text-align: center; }

/* ===== Điện thoại / máy tính bảng ===== */
.backdrop { display: none; }
@media (max-width: 900px) {
    .frame { padding: 12px 12px 24px; }
    .header { grid-template-columns: 1fr auto; padding: 10px 12px 10px 10px; height: auto; border-radius: 28px; row-gap: 10px; }
    .header-nav { grid-column: 1 / -1; order: 3; overflow-x: auto; scrollbar-width: none; }
    .header-nav a { white-space: nowrap; padding: 8px 16px; }
    .menu-btn { display: grid; width: 40px; height: 40px; }
    .header-right .round-btn { width: 40px; height: 40px; }
    .body { grid-template-columns: minmax(0, 1fr); padding-left: 0; margin-top: 18px; }
    .sidebar { position: fixed; z-index: 20; left: 12px; top: 130px; bottom: 12px; min-height: 0; transform: translateX(-140%); transition: transform .22s; }
    .nav-open .sidebar { transform: none; }
    .nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 10; }
    .side-item::after { display: none; }
    .page-title { font-size: 1.6rem; }
}

/* ===== Nút sáng/tối: mặt trời lặn, mặt trăng mọc (đơn sắc) ===== */
.theme-btn .sky { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; }
.theme-btn .sky svg { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; transition: transform .6s cubic-bezier(.3, 1.2, .5, 1), opacity .4s ease; }
.theme-btn .sun  { transform: none; }
.theme-btn .moon { transform: translateY(30px) rotate(-30deg); opacity: 0; }
:root[data-theme="dark"] .theme-btn .sun  { transform: translateY(30px) rotate(60deg); opacity: 0; }
:root[data-theme="dark"] .theme-btn .moon { transform: none; opacity: 1; }

/* Chuyển màu mượt toàn trang khi đổi giao diện */
.theme-switching, .theme-switching *, .theme-switching *::before, .theme-switching *::after {
    transition: background-color .45s ease, color .45s ease, border-color .45s ease !important;
}
.theme-switching .sky svg { transition: transform .6s cubic-bezier(.3, 1.2, .5, 1), opacity .4s ease !important; }
@media (prefers-reduced-motion: reduce) { .sky svg { transition: none !important; } }

/* Mục lớn trống */
.card.empty { text-align: center; padding: 48px 20px; }
.card.empty h2 { margin: 12px 0 6px; }
.empty-ico { width: 56px; height: 56px; margin: 0 auto; border-radius: 50%; background: var(--tint); display: grid; place-items: center; color: var(--tint-text); }

/* ===== Job: chấm màu, thanh tab phụ, chọn màu ===== */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.header-nav a { display: inline-flex; align-items: center; gap: 8px; }
.subhead { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 22px; }
.job-badge { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.subnav { display: flex; gap: 4px; background: var(--surface); border-radius: 999px; padding: 5px; max-width: 100%; overflow-x: auto; }
.subnav a { padding: 7px 18px; border-radius: 999px; color: var(--muted); font-weight: 500; font-size: .9rem; white-space: nowrap; }
.subnav a:hover { color: var(--text); }
.subnav a.active { background: var(--soft); color: var(--text); }
.stat { display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.stat strong { font-size: 1.8rem; font-weight: 500; }
.form-label { font-size: .88rem; color: var(--muted); margin-bottom: -6px; }
.swatches { display: flex; gap: 10px; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.swatch span { display: block; width: 30px; height: 30px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px transparent, 0 0 0 4px transparent; transition: box-shadow .15s; }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.swatch input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 4px; }

/* Chữ cái đầu của job trong sidebar */
.side-item .ico-text { font-size: 1rem; font-weight: 700; }
.header-nav { max-width: 100%; }

/* Trên nền màu (xanh/màu job) chữ luôn trắng, ở cả sáng và tối */
.side-item.active,
:root[data-theme="dark"] .side-item.active,
.side-item.active:hover,
.avatar, .btn:not(.btn-ghost) { color: #fff; }

/* ===== Ảnh đại diện job ===== */
.side-item img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.side-item[data-img].active { background: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ring, var(--primary)); }
.badge-img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.avatar-field { display: flex; align-items: center; gap: 16px; }
.avatar-preview { width: 64px; height: 64px; flex: none; border-radius: 50%; background: var(--c, var(--primary)); color: #fff; display: grid; place-items: center; font-size: 1.4rem; font-weight: 700; overflow: hidden; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-actions { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.avatar-actions input[type=file] { padding: 8px 10px; }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; }
.check input { width: auto; }

/* Viền sáng cho mục đang chọn ở dark mode (nền xanh đậm trên nền tối) */
:root[data-theme="dark"] .side-item.active { box-shadow: 0 0 0 1px rgba(142, 182, 155, .45); }
:root[data-theme="dark"] .side-item[data-img].active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ring, #8EB69B); }
/* Màu job sáng (#8EB69B): chữ tối để đọc được */
.side-item.active[style*="8EB69B"] { color: #051F20; }

:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* Ô chọn (select): mũi tên tự vẽ, cách lề phải */
select {
    -webkit-appearance: none; appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b8b90' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
}
