:root {
    --bg-main:     #0d0f17;
    --bg-card:     #12141f;
    --bg-input:    #1a1d2b;
    --bg-hover:    #1f2235;
    --text-main:   #a9b1d6;
    --text-bright: #e0e4ff;
    --accent:      #ff4500;
    --accent-dim:  rgba(255,69,0,0.12);
    --accent-border: rgba(255,69,0,0.35);
    --danger:      #f7768e;
    --success:     #73daca;
    --warn:        #e0af68;
    --border:      rgba(255,255,255,0.07);
    --muted:       #565f89;
    --sidebar-w:   220px;
}

.light {
    --bg-main:     #f0f2f8;
    --bg-card:     #ffffff;
    --bg-input:    #f0f2f8;
    --bg-hover:    #e8eaf4;
    --text-main:   #3b3f5c;
    --text-bright: #1a1d2e;
    --accent:      #ff4500;
    --accent-dim:  rgba(255,69,0,0.08);
    --accent-border: rgba(255,69,0,0.3);
    --danger:      #d93b55;
    --success:     #2e8b57;
    --warn:        #b8860b;
    --border:      rgba(0,0,0,0.08);
    --muted:       #8b90b0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 14px;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
h2, h3, h4 { color: var(--text-bright); font-weight: 600; }

/* Login */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 0;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2.5rem;
    width: 360px;
}

.login-logo {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.login-logo::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.login-box h2 {
    font-size: 20px;
    margin-bottom: 0.25rem;
    border: none;
    padding: 0;
}

.login-box .sub {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 1.8rem;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 10;
}

.sidebar-brand {
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--border);
}

.brand-logo {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-logo::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.brand-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 3px;
    padding-left: 16px;
}

.nav-section {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 16px 18px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    color: var(--muted);
    cursor: pointer;
    border-left: 2px solid transparent;
    font-size: 13px;
    transition: all 0.15s;
    text-decoration: none;
}

.nav-item:hover {
    color: var(--text-main);
    background: var(--bg-hover);
    text-decoration: none;
}

.nav-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-dim);
}

.nav-icon { font-size: 15px; flex-shrink: 0; }

.sidebar-bottom {
    margin-top: auto;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
}

.user-name { font-size: 13px; color: var(--text-bright); font-weight: 600; }
.user-role { font-size: 11px; color: var(--muted); }

/* Main */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 24px 28px;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title { font-size: 18px; font-weight: 700; color: var(--text-bright); }
.page-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.theme-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
}

.theme-btn:hover { color: var(--text-main); opacity: 1; }

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}

.stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
}

.stat-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1;
}

.stat-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 18px;
}

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

.card-title { font-size: 14px; font-weight: 600; color: var(--text-bright); }

/* Forms */
label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: block;
    margin-bottom: 4px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-bright);
    border-radius: 7px;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
}

input:focus, select:focus { border-color: var(--accent); }

input[type="file"] {
    background: var(--bg-input);
    border: 1px dashed var(--border);
    color: var(--text-main);
    border-radius: 7px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    width: 100%;
}

.form-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group { display: flex; flex-direction: column; }
.form-group-wide { flex: 1; min-width: 160px; }
.form-group-sm input { width: 72px; }

/* Buttons */
button {
    padding: 9px 18px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s;
}

button:hover { opacity: 0.88; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--bg-input); color: var(--text-main); border: 1px solid var(--border); }
.btn-danger   { background: transparent; border: 1px solid var(--danger); color: var(--danger); padding: 5px 12px; font-size: 12px; }
.btn-danger:hover { background: rgba(247,118,142,0.1); opacity: 1; }
.btn-logout   { background: var(--bg-input); color: var(--muted); border: 1px solid var(--border); padding: 7px 14px; font-size: 12px; }

/* Table */
table { width: 100%; border-collapse: collapse; }

th {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-weight: 500;
}

td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-bright);
    font-size: 13px;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-ok      { background: rgba(115,218,202,0.12); color: var(--success); }
.badge-expired { background: rgba(247,118,142,0.12); color: var(--danger); }
.badge-never   { background: var(--bg-input); color: var(--muted); }
.badge-hwid    { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-border); }
.badge-nohwid  { background: var(--bg-input); color: var(--muted); }

/* Token */
.token-container { display: flex; align-items: center; gap: 8px; }

code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    background: var(--bg-input);
    padding: 3px 8px;
    border-radius: 5px;
    color: var(--accent);
    border: 1px solid var(--border);
}

.btn-copy {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 3px 9px;
    font-size: 11px;
    border-radius: 5px;
    font-weight: 500;
}

.btn-copy:hover { color: var(--text-bright); opacity: 1; }

/* HWID cell */
.hwid-text {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
    color: var(--accent);
}

.hwid-none {
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
}

/* File list */
.file-list { display: flex; flex-direction: column; gap: 8px; }

.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.file-info { display: flex; align-items: center; gap: 10px; }
.file-icon { color: var(--muted); display: inline-flex; vertical-align: middle; margin-right: 4px; }
.file-name { font-size: 13px; color: var(--text-bright); font-weight: 500; }
.file-actions { display: flex; align-items: center; gap: 8px; }

/* Alerts */
.error {
    background: rgba(247,118,142,0.08);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid rgba(247,118,142,0.2);
    font-size: 13px;
}

.msg {
    background: var(--accent-dim);
    color: var(--accent);
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--accent-border);
    font-size: 13px;
}

/* Upload */
.upload-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    width: 100%;
}

.empty-state {
    text-align: center;
    padding: 24px;
    color: var(--muted);
    font-size: 13px;
}

label.btn-secondary {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
label.btn-secondary:hover { opacity: 0.88; }

/* Toasts */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; }
.toast { background: var(--bg-card); color: var(--text-bright); border: 1px solid var(--border); padding: 12px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,0.25); opacity: 0; transform: translateY(10px); transition: opacity 0.25s, transform 0.25s; max-width: 320px; }
.toast-show { opacity: 1; transform: translateY(0); }
.toast-error { border-color: var(--danger); color: var(--danger); }

/* Drag and drop upload */
.drop-zone { border: 2px dashed var(--border); border-radius: 10px; padding: 24px; text-align: center; width: 100%; transition: border-color 0.15s, background 0.15s; }
.drop-zone-active { border-color: var(--accent); background: var(--accent-dim); }
.drop-zone-content { font-size: 13px; color: var(--muted); }
.drop-zone-browse { color: var(--accent); cursor: pointer; text-decoration: underline; }
.upload-progress-wrap { display: flex; align-items: center; gap: 10px; margin-top: 10px; width: 100%; }
.upload-progress-track { flex: 1; height: 8px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.upload-progress-bar { height: 100%; width: 0%; background: var(--accent); transition: width 0.15s; }
.upload-progress-text { font-size: 12px; color: var(--muted); width: 40px; text-align: right; }

/* Expiry relative time */
.expiry-relative { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Mobile */
.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    font-size: 16px;
    cursor: pointer;
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 90; }
.sidebar-overlay.sidebar-overlay-visible { display: block; }
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 768px) {
    .hamburger-btn { display: inline-flex; }
    .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; z-index: 100; }
    .sidebar.sidebar-open { transform: translateX(0); }
    .main { margin-left: 0; padding: 16px; }
    .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .topbar { flex-wrap: wrap; gap: 10px; }
    .drop-zone { padding: 16px; }
}

/* Native-feel polish */
* { -webkit-tap-highlight-color: transparent; }
button, .btn-primary, .btn-secondary, .btn-danger, .btn-logout, label.btn-secondary {
    -webkit-user-select: none; user-select: none;
    transition: opacity 0.15s, transform 0.1s;
}
button:active, .btn-primary:active, .btn-secondary:active, .btn-danger:active, .btn-logout:active, label.btn-secondary:active {
    transform: scale(0.96);
    opacity: 0.8;
}
.topbar { position: sticky; top: 0; background: var(--bg-main); z-index: 20; padding-top: 4px; padding-bottom: 4px; }

@media (max-width: 768px) {
    input[type="text"], input[type="password"], input[type="number"], select {
        font-size: 16px;
    }
    .card form > .form-row > .form-group:last-child button,
    #uploadSubmitBtn {
        width: 100%;
    }
    .btn-copy, .btn-danger { min-height: 32px; }
}

/* Fix mobile viewport height (100vh vs real visible area) */
body { min-height: 100dvh; }
.layout { min-height: 100dvh; }
.sidebar { height: 100dvh; }
.main { min-height: 100dvh; }

html { overflow-x: hidden; width: 100%; }
body { overflow-x: hidden; width: 100%; max-width: 100vw; position: relative; }
.layout { overflow-x: hidden; max-width: 100vw; }

.main { min-width: 0; }
