:root {
    --bg: #101214;
    --bg-elev: #171a1e;
    --panel: rgba(22, 25, 30, 0.82);
    --panel-solid: #1b1f25;
    --line: rgba(255, 255, 255, 0.08);
    --text: #f4f6f7;
    --muted: #9aa3ab;
    --green: #7cb342;
    --green-2: #9ccc65;
    --yellow: #f5c542;
    --danger: #ef9a9a;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    --radius: 16px;
    --taskbar-h: 56px;
    font-family: "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--text); background: var(--bg); }
body { line-height: 1.45; }
a { color: var(--green-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.hidden { display: none !important; }

.btn,
.task-link,
button.task-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    background: transparent;
    color: var(--text);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(180deg, #8bc34a, #689f38);
    color: #101210;
    font-weight: 650;
    box-shadow: 0 8px 20px rgba(124, 179, 66, 0.22);
}
.btn-primary:hover { filter: brightness(1.05); text-decoration: none; }
.btn-ghost {
    background: rgba(255,255,255,0.04);
    border-color: var(--line);
}
.btn-ghost:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.btn:focus-visible,
.task-link:focus-visible,
.app-tile:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.window-close:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 2px;
}

.stack { display: grid; gap: 14px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
label { display: grid; gap: 6px; font-size: 0.92rem; color: #d7dde2; }
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: rgba(8, 10, 12, 0.55);
    border-radius: 10px;
    padding: 11px 12px;
}
.check { display: flex; align-items: center; gap: 10px; }

.alert {
    border-radius: 12px;
    padding: 12px 14px;
    margin: 0 0 16px;
}
.alert-error { background: rgba(239, 154, 154, 0.12); color: #ffcdd2; }
.alert-ok { background: rgba(124, 179, 66, 0.14); color: #dcedc8; }

.brand-mark { display: flex; gap: 8px; margin-bottom: 10px; }
.brand-dot {
    width: 12px; height: 12px; border-radius: 50%;
    display: inline-block;
}
.brand-dot.green { background: var(--green); box-shadow: 0 0 12px rgba(124,179,66,.6); }
.brand-dot.yellow { background: var(--yellow); box-shadow: 0 0 12px rgba(245,197,66,.45); }

/* Auth */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(900px 500px at 15% -10%, rgba(124,179,66,0.16), transparent 55%),
        radial-gradient(700px 420px at 110% 10%, rgba(245,197,66,0.10), transparent 50%),
        #0c0e10;
}
.auth-card {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 32px 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}
.auth-card h1 { margin: 4px 0 8px; font-size: 2rem; letter-spacing: -0.03em; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem; color: var(--green-2); margin: 0; }

/* Desktop */
.desktop-body {
    min-height: 100vh;
    padding: 20px 20px calc(var(--taskbar-h) + 24px);
    overflow-x: hidden;
}
.desktop-bg {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(1200px 700px at 8% -20%, rgba(124,179,66,0.13), transparent 50%),
        radial-gradient(900px 600px at 92% 0%, rgba(245,197,66,0.08), transparent 46%),
        linear-gradient(180deg, #14171b 0%, #0d0f12 100%);
}
.desktop-header,
.desktop-grid,
.taskbar,
.workspace-window { position: relative; z-index: 1; }

.desktop-header { margin-bottom: 18px; }
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-brand span { display: block; color: var(--muted); font-size: 0.82rem; }

.desktop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 16px;
    max-width: 1180px;
}

.app-tile {
    appearance: none;
    text-align: left;
    background: rgba(255,255,255,0.035);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 16px 16px;
    min-height: 168px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.18);
    transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.app-tile:hover {
    transform: translateY(-3px);
    background: rgba(255,255,255,0.06);
    border-color: rgba(124,179,66,0.35);
    text-decoration: none;
}
.app-icon {
    width: 56px; height: 56px;
    border-radius: 16px;
    display: grid; place-items: center;
    background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));
    margin-bottom: 14px;
}
.app-title { display: block; font-weight: 650; }
.app-desc { display: block; margin-top: 4px; color: var(--muted); font-size: 0.8rem; }
.empty-desktop { color: var(--muted); }

/* Window */
.window-backdrop {
    position: fixed; inset: 0; z-index: 20;
    background: rgba(0,0,0,0.35);
}
.workspace-window {
    position: fixed;
    z-index: 30;
    left: 50%;
    top: 46%;
    transform: translate(-50%, -50%);
    width: min(760px, calc(100vw - 28px));
    height: min(620px, calc(100vh - var(--taskbar-h) - 36px));
    background: var(--panel-solid);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.window-chrome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,0.03);
}
.window-titlewrap { display: flex; align-items: center; gap: 8px; }
.window-titlewrap h2 { margin: 0; font-size: 0.95rem; font-weight: 600; }
.window-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.window-close {
    width: 34px; height: 34px; border: 0; border-radius: 8px;
    background: transparent; color: var(--text); font-size: 1.3rem; cursor: pointer;
}
.window-close:hover { background: rgba(239,154,154,0.16); }
.workspace-window iframe {
    flex: 1; width: 100%; border: 0; background: #12151a;
}

/* Taskbar */
.taskbar {
    position: fixed;
    left: 12px; right: 12px; bottom: 10px;
    z-index: 40;
    height: var(--taskbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 12px;
    background: rgba(16, 18, 21, 0.82);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
.taskbar-left, .taskbar-right { display: flex; align-items: center; gap: 10px; }
.taskbar-logo { display: flex; align-items: center; gap: 6px; font-weight: 700; letter-spacing: 0.04em; }
.task-user, #task-clock { color: #d7dde2; font-size: 0.9rem; white-space: nowrap; }
#task-clock { font-variant-numeric: tabular-nums; min-width: 54px; text-align: right; }
.task-link.danger, button.danger { color: var(--danger); }
.task-item {
    background: rgba(124,179,66,0.14);
    border-color: rgba(124,179,66,0.28);
    padding: 7px 12px;
    font-size: 0.88rem;
}

/* Tools / admin */
.tool-body, .admin-body { min-height: 100vh; background: #12151a; }
.tool-body.embedded { background: #161a20; }
.tool-topbar, .admin-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,0.02);
}
.admin-nav { display: flex; gap: 14px; align-items: center; color: var(--muted); }
.tool-panel, .admin-main { width: min(980px, calc(100% - 32px)); margin: 24px auto 40px; }
.tool-intro h1, .admin-main h1 { margin: 0 0 8px; letter-spacing: -0.03em; }
.qr-form, .admin-form, .qr-preview {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    margin-top: 16px;
}
.qr-preview { min-height: 220px; display: grid; place-items: center; }
#qr-canvas { background: #fff; padding: 12px; border-radius: 12px; }
#qr-canvas:empty { display: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.toolbar { margin: 0 0 16px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
.actions { display: flex; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 0.78rem; }
.pill.on { background: rgba(124,179,66,0.18); color: #dcedc8; }
.pill.off { background: rgba(255,255,255,0.06); color: var(--muted); }

@media (max-width: 720px) {
    .desktop-grid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 12px; }
    .app-tile { min-height: 148px; padding: 14px; }
    .taskbar { left: 8px; right: 8px; padding: 0 8px; }
    .task-user { display: none; }
    .workspace-window { height: calc(100vh - var(--taskbar-h) - 20px); top: calc(50% - 8px); border-radius: 14px; }
}

.start-menu { position:fixed; bottom:calc(var(--taskbar-h) + 24px); left:18px; z-index:100; display:grid; width:min(310px,calc(100vw - 36px)); max-height:70vh; overflow:auto; padding:16px; background:var(--panel-solid); border:1px solid var(--line); border-radius:16px; box-shadow:var(--shadow); }
.start-menu .task-link { justify-content:flex-start; }
.actions { flex-wrap:wrap; }
#qr-canvas { border-radius:0; padding:0; max-width:100%; }
#qr-canvas canvas { max-width:100%; height:auto; display:block; }
button:disabled { opacity:.45; cursor:default; }
