:root {
    --ink: #1A2730;
    --panel: #424048;
    --muted: #45586C;
    --mist: #B0CEE2;
    --rust: #A63E18;
    --orange: #E95D2C;
    --bg: #f5f8fb;
    --text: #1A2730;
    --card: #ffffff;
    --line: rgba(69, 88, 108, 0.22);
}

[data-theme="dark"] {
    --bg: #1A2730;
    --text: #f5f8fb;
    --card: #273744;
    --line: rgba(176, 206, 226, 0.22);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, Arial, Helvetica, sans-serif;
}

.hidden { display: none !important; }
.app-shell { min-height: 100vh; display: flex; }
.brand { font-size: 22px; font-weight: 800; line-height: 1.15; }
.brand span { display: block; color: var(--mist); font-size: 13px; margin-top: 6px; }

.content { flex: 1; min-width: 0; }
.topbar {
    min-height: 72px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
    background: var(--card);
}
.top-actions { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.page { padding: 24px; }
.grid { display: grid; gap: 18px; }
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 16px 40px rgba(26,39,48,0.08);
}
.card-title { margin: 0 0 14px; font-size: 18px; }
.form-grid { display: grid; gap: 12px; }
.create-user-form {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(160px, 1fr) 170px auto;
    gap: 12px;
    align-items: end;
}
label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
[data-theme="dark"] label { color: var(--mist); }
input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    background: var(--bg);
    color: var(--text);
    outline: none;
}
input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(233,93,44,0.18); }
.button {
    border: 0;
    border-radius: 8px;
    padding: 11px 14px;
    font-weight: 800;
    cursor: pointer;
    color: white;
    background: var(--muted);
}
.button.primary { background: var(--orange); }
.button.danger { background: var(--rust); }
.button.ghost { color: var(--text); background: transparent; border: 1px solid var(--line); }
.button.small { padding: 8px 10px; font-size: 12px; }
.button:disabled { opacity: 0.55; cursor: wait; }
.icon-button {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    flex: 0 0 auto;
}
.icon-button svg { width: 18px; height: 18px; stroke: currentColor; }
.icon-button:hover { border-color: var(--orange); color: var(--orange); }
.icon-button.danger { background: var(--rust); border-color: var(--rust); color: white; }
.icon-button.danger:hover { background: var(--orange); border-color: var(--orange); color: white; }
.action-row { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.action-row .icon-button { width: 34px; height: 34px; }
.profile-button {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--mist);
    border-radius: 50%;
    background: var(--muted);
    color: white;
    cursor: pointer;
}
.profile-button svg { width: 20px; height: 20px; stroke: currentColor; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 52px; }
.password-field .input-icon {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: transparent;
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.stat strong { display: block; font-size: 26px; }
.stat span { color: var(--muted); font-size: 13px; font-weight: 700; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1120px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.license-col { width: 150px; }
.license-input {
    width: 136px;
    min-width: 136px;
    padding: 8px 6px;
}
.table-search {
    width: min(300px, 100%);
    max-width: 100%;
}
.date-cell { white-space: nowrap; font-size: 13px; color: var(--text); }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 800; background: var(--mist); color: var(--ink); }
.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 22px;
    background: linear-gradient(135deg, var(--ink), var(--muted));
}
.login-card { width: min(420px, 100%); background: white; color: var(--ink); border-radius: 8px; padding: 24px; }
.toast {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    width: min(360px, calc(100% - 32px));
    background: var(--ink);
    color: white;
    padding: 12px 14px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 16px 40px rgba(0,0,0,0.22);
}
.toast.error {
    background: var(--orange);
}
.modal {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(26,39,48,0.55);
}
.modal-panel {
    width: min(560px, 100%);
    background: var(--card);
    color: var(--text);
    border-radius: 8px;
    padding: 18px;
    border: 1px solid var(--line);
}
.password-box {
    word-break: break-all;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.profile-page {
    min-height: calc(100vh - 72px);
    display: grid;
    place-items: center;
}
.profile-card { width: min(560px, 100%); }

@media (max-width: 920px) {
    .app-shell { display: block; }
    .topbar { align-items: flex-start; }
    .stat-row { grid-template-columns: 1fr; }
    .create-user-form { grid-template-columns: 1fr; }
}
