:root {
    --sidebar-bg: #101826;
    --sidebar-text: #94a3b8;
    --sidebar-active: #1c2a3f;
    --accent: #2f7d6d;
    --accent-soft: #e4f2ee;
    --bg: #f3f5f8;
    --card: #ffffff;
    --border: #e3e8ef;
    --text: #1a2332;
    --muted: #7a8699;
    --danger: #c0392b;
    --aktif: #1e8e5a;
    --dipinjam: #b7791f;
    --rusak: #c0392b;
    --tidak-dipakai: #64748b;
    --input-bg: #ffffff;
    --radius: 10px;
}

[data-theme="dark"] {
    --sidebar-bg: #0b111c;
    --sidebar-text: #8d9bb0;
    --sidebar-active: #17233a;
    --accent: #3d9c88;
    --accent-soft: #16302b;
    --bg: #121822;
    --card: #1a2230;
    --border: #2b3648;
    --text: #e6ebf3;
    --muted: #93a1b5;
    --danger: #e57368;
    --aktif: #3aa76d;
    --dipinjam: #d0a03f;
    --rusak: #e0655a;
    --tidak-dipakai: #8d9bb0;
    --input-bg: #212b3b;
}

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

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.brand-icon { font-size: 24px; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; letter-spacing: 0.5px; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 3px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover { background: rgba(255,255,255,0.05); color: #e2e8f0; }
.sidebar-nav a.active { background: var(--accent); color: #fff; }
.nav-ico { width: 20px; text-align: center; }

.nav-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 16px 12px 6px;
    color: #5a6a80;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.user-name { color: #e2e8f0; font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; }
.logout-link { color: var(--sidebar-text); font-size: 12px; text-decoration: none; }
.logout-link:hover { color: #fff; }

.content { flex: 1; margin-left: 240px; padding: 28px 32px; }

.page-head { margin-bottom: 22px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.page-head h1 { font-size: 22px; flex-basis: 100%; }
.page-sub { color: var(--muted); flex: 1; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    border-left: 4px solid var(--muted);
}

.stat-total { border-left-color: var(--accent); }
.stat-aktif { border-left-color: var(--aktif); }
.stat-dipinjam { border-left-color: var(--dipinjam); }
.stat-rusak { border-left-color: var(--rusak); }

.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 32px; font-weight: 700; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.card-head { font-weight: 700; margin-bottom: 14px; font-size: 15px; }

.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted);
    padding: 8px 10px;
    border-bottom: 2px solid var(--border);
}
.table td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}

.badge-aktif { background: var(--aktif); }
.badge-dipinjam { background: var(--dipinjam); }
.badge-rusak { background: var(--rusak); }

.dot-online {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: #22c55e;
    margin-right: 6px;
    animation: pulse 1.4s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
    70% { box-shadow: 0 0 0 7px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

.online-text { color: var(--aktif); font-weight: 600; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, monospace; font-size: 12px; }
.banks { white-space: pre-line; font-size: 13px; }
.empty { color: var(--muted); padding: 20px 0; text-align: center; }

.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s;
}

.btn:hover { filter: brightness(0.96); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: #fdf0ee; border-color: #f3c4bd; color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 14px; }

.actions { white-space: nowrap; }
.actions form { display: inline; }
.actions .btn { margin-right: 4px; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; align-items: center; }
.filter-bar select { width: auto; min-width: 160px; }

label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 5px; }

input[type=text], input[type=password], input[type=file], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { flex: 1; }

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-weight: 500;
}

.alert-success { background: #e4f2ee; color: #145c4c; border: 1px solid #b8ddd3; }
.alert-danger { background: #fdf0ee; color: #8c2b1f; border: 1px solid #f3c4bd; }

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16,24,38,0.55);
    z-index: 50;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 16px;
    overflow-y: auto;
}

.modal-backdrop.show { display: flex; }

.modal {
    background: var(--card);
    border-radius: 12px;
    padding: 22px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.modal-head {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close { margin-left: auto; cursor: pointer; color: var(--muted); }
.modal-close:hover { color: var(--text); }

.video-link {
    display: inline-block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.user-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 15px;
}

.user-card-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.user-card-actions input { width: 150px; }

.store-checks { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 12px; }

.check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    margin: 0;
    background: var(--bg);
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
}

.check input { width: auto; }

.steps { padding-left: 20px; line-height: 1.9; }
.steps code { background: var(--bg); padding: 2px 6px; border-radius: 5px; font-size: 12px; }

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--sidebar-bg);
}

.login-card {
    background: var(--card);
    border-radius: 14px;
    padding: 36px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-logo { font-size: 40px; margin-bottom: 10px; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-sub { color: var(--muted); margin-bottom: 20px; }
.login-card form { text-align: left; }

@media (max-width: 900px) {
    .sidebar { width: 68px; }
    .sidebar-brand div, .user-chip div, .nav-section { display: none; }
    .sidebar-nav a { justify-content: center; font-size: 0; gap: 0; }
    .sidebar-nav a .nav-ico { font-size: 18px; }
    .logout-link { font-size: 0; }
    .theme-toggle { justify-content: center; font-size: 0; gap: 0; padding: 9px 4px; }
    .theme-toggle .ticon { font-size: 16px; }
    .logout-link::after { content: "→"; font-size: 16px; }
    .content { margin-left: 68px; padding: 20px 16px; }
    .grid-2 { grid-template-columns: 1fr; }
}

.scan-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
    align-items: start;
}

.scan-stage { text-align: center; padding: 28px 20px; }

.scan-visual {
    position: relative;
    width: 130px;
    height: 130px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-icon { font-size: 44px; }

.scan-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid var(--border);
}

.scan-ring.spinning {
    border-top-color: var(--accent);
    animation: spin 0.9s linear infinite;
}

.scan-ring.live {
    border-color: var(--aktif);
    animation: breathe 2s ease-in-out infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes breathe {
    0%, 100% { box-shadow: 0 0 0 0 rgba(30,142,90,0.35); }
    50% { box-shadow: 0 0 0 12px rgba(30,142,90,0); }
}

.scan-state { font-size: 17px; font-weight: 700; margin-bottom: 5px; }
.scan-hint { color: var(--muted); font-size: 13px; min-height: 34px; }

.scan-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.scan-clock { font-size: 12px; color: var(--muted); margin-top: 14px; }

@media (prefers-reduced-motion: reduce) {
    .scan-ring.spinning, .scan-ring.live, .dot-online { animation: none; }
}

@media (max-width: 900px) {
    .scan-layout { grid-template-columns: 1fr; }
}

.usb-chip {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 24px;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(16,24,38,0.12);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
}

.usb-chip:hover { border-color: var(--accent); color: var(--text); }
.usb-chip.on { color: var(--aktif); border-color: #bfe3d0; }

.usb-chip-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #cbd3de;
}

#serial-picker select { margin-bottom: 4px; }
#add-serial[readonly] { background: var(--bg); color: var(--muted); }

.absen-stats { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.astat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 12.5px;
    color: var(--muted);
}

.astat b { color: var(--text); margin-left: 4px; font-size: 14px; }
.astat-ok { border-color: #bfe3d0; }
.astat-ok b { color: var(--aktif); }
.astat-no { border-color: #f3c4bd; }
.astat-no b { color: var(--rusak); }

.absen-yes { color: var(--aktif); font-weight: 600; white-space: nowrap; }
.absen-no { color: var(--rusak); font-weight: 600; white-space: nowrap; }

.filter-bar { flex-wrap: wrap; }
.filter-bar input[type=date] { width: auto; }

.borrowed-to { font-size: 11px; color: var(--dipinjam); margin-top: 4px; font-weight: 600; }
.btn-return { background: #e4f2ee; border-color: #b8ddd3; color: #145c4c; }

.badge-tidak-dipakai { background: var(--tidak-dipakai); }
.stat-tidak-dipakai { border-left-color: var(--tidak-dipakai); }

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: var(--sidebar-text);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.theme-toggle:hover { background: rgba(255,255,255,0.12); color: #e2e8f0; }
.theme-toggle .ticon { font-size: 14px; }

[data-theme="dark"] .alert-success {
    background: #16302b;
    color: #8fdcc4;
    border-color: #2c5a4e;
}

[data-theme="dark"] .alert-danger {
    background: #3a1f1c;
    color: #f0a79e;
    border-color: #6b352f;
}

[data-theme="dark"] .btn-danger {
    background: #3a1f1c;
    border-color: #6b352f;
    color: #f0a79e;
}

[data-theme="dark"] .btn-return {
    background: #16302b;
    border-color: #2c5a4e;
    color: #8fdcc4;
}

[data-theme="dark"] .astat-ok { border-color: #2c5a4e; }
[data-theme="dark"] .astat-no { border-color: #6b352f; }

[data-theme="dark"] .usb-chip { box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
[data-theme="dark"] .modal { box-shadow: 0 20px 50px rgba(0,0,0,0.6); }
[data-theme="dark"] .badge { color: #0f1620; }
[data-theme="dark"] .btn-primary { color: #0f1620; }
[data-theme="dark"] .sidebar-nav a.active { color: #0f1620; }
[data-theme="dark"] .user-avatar { color: #0f1620; }
[data-theme="dark"] input[type=date] { color-scheme: dark; }
[data-theme="dark"] .dot-online { background: #3aa76d; }

.act-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
}

.act-tambah { background: #e4f2ee; color: #145c4c; border-color: #b8ddd3; }
.act-status { background: #fff4de; color: #8a5a10; border-color: #f0d894; }
.act-kembali { background: #e4f2ee; color: #145c4c; border-color: #b8ddd3; }
.act-transfer { background: #e6eefb; color: #1f4b8f; border-color: #bfd3f0; }
.act-edit { background: #eef0f4; color: #46536b; border-color: #d7dce5; }
.act-hapus { background: #fdf0ee; color: #8c2b1f; border-color: #f3c4bd; }

[data-theme="dark"] .act-tambah { background: #16302b; color: #8fdcc4; border-color: #2c5a4e; }
[data-theme="dark"] .act-status { background: #3a3016; color: #e2c574; border-color: #6b5a2a; }
[data-theme="dark"] .act-kembali { background: #16302b; color: #8fdcc4; border-color: #2c5a4e; }
[data-theme="dark"] .act-transfer { background: #1a2a44; color: #9dc0ef; border-color: #33507e; }
[data-theme="dark"] .act-edit { background: #242c3a; color: #b3bfd2; border-color: #3b4658; }
[data-theme="dark"] .act-hapus { background: #3a1f1c; color: #f0a79e; border-color: #6b352f; }

.log-time strong { font-size: 14px; }
.log-time .muted { font-size: 11px; }
.log-detail { font-size: 13px; max-width: 340px; }
.log-search { width: 180px !important; }

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding-top: 16px;
    margin-top: 6px;
    border-top: 1px solid var(--border);
}

.filter-bar input[type=date] { width: auto; }


}


}

.chat-card { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 460px; padding: 0; }

.chat-head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.chat-ava {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 17px;
}

.chat-name { font-weight: 700; font-size: 15px; }
.chat-sub { font-size: 11px; color: var(--muted); }

.chat-body { flex: 1; overflow-y: auto; padding: 20px 18px; }

.chat-welcome { text-align: center; padding: 20px 10px 10px; }

.cw-ava {
    width: 58px; height: 58px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 26px;
    margin: 0 auto 12px;
}

.chat-welcome h3 { font-size: 17px; margin-bottom: 5px; }
.chat-welcome p { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.chip {
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.chip:hover { border-color: var(--accent); color: var(--accent); }

.msg { display: flex; gap: 10px; margin-bottom: 16px; align-items: flex-start; }
.msg-me { justify-content: flex-end; }

.msg-ava {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 13px;
    flex-shrink: 0;
}

.msg-bubble {
    max-width: 76%;
    padding: 11px 15px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.65;
    background: var(--bg);
    border: 1px solid var(--border);
}

.msg-me .msg-bubble {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    border-bottom-right-radius: 4px;
}

.msg-ai .msg-bubble { border-bottom-left-radius: 4px; }

.msg-bubble pre {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 9px 11px;
    border-radius: 7px;
    overflow-x: auto;
    font-size: 12px;
    margin: 7px 0;
    white-space: pre-wrap;
}

.msg-bubble code { background: var(--card); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

.bubble-err { border-color: var(--danger) !important; color: var(--danger); }

.typing { display: inline-flex; gap: 4px; vertical-align: middle; }
.typing i {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--muted);
    animation: blink 1.3s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink { 0%,60%,100% { opacity:0.25 } 30% { opacity:1 } }

.think-note { font-size: 12px; color: var(--muted); margin-left: 8px; }

.steps-box { margin-top: 9px; font-size: 12px; }
.steps-box summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.steps-box ul { margin: 7px 0 0; padding-left: 18px; color: var(--muted); }
.steps-box li { margin-bottom: 3px; }

.chat-input-wrap {
    display: flex;
    gap: 9px;
    padding: 13px 18px;
    border-top: 1px solid var(--border);
    align-items: flex-end;
}

.chat-input-wrap textarea {
    flex: 1;
    resize: none;
    max-height: 140px;
    line-height: 1.5;
}

[data-theme="dark"] .msg-me .msg-bubble { color: #0f1620; }
[data-theme="dark"] .chat-ava, [data-theme="dark"] .cw-ava, [data-theme="dark"] .msg-ava { color: #0f1620; }

@media (max-width: 700px) {
    .chat-card { height: calc(100vh - 150px); }
    .msg-bubble { max-width: 88%; }
}

.token-reveal {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.token-reveal code {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    word-break: break-all;
    flex: 1;
    min-width: 260px;
}

.api-pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    overflow-x: auto;
    font-size: 12.5px;
    font-family: Consolas, monospace;
    line-height: 1.6;
    white-space: pre;
    color: var(--text);
    margin: 6px 0 14px;
}

.card h3 { font-size: 13px; margin: 16px 0 6px; color: var(--accent); }
