@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap");

@view-transition { navigation: auto; }

:root {
    --ink: #17233b;
    --muted: #66738a;
    --line: #e6ebf3;
    --paper: #ffffff;
    --ground: #f2f4fb;
    --brand: #13527a;
    --brand-soft: #e3eef5;
    --violet: #5a48c4;
    --night: #0b1736;
    --night-mid: #15295f;
    --night-end: #33297f;
    --accent: linear-gradient(120deg, var(--brand), var(--violet));
    --good: #0f8a5f;
    --good-soft: #e0f6ec;
    --bad: #cf3341;
    --bad-soft: #fde8ea;
    --warn: #a86a00;
    --warn-soft: #fdf2d8;
    --shadow-sm: 0 1px 2px rgba(23, 35, 59, .05);
    --shadow: 0 1px 2px rgba(23, 35, 59, .04), 0 10px 28px rgba(23, 35, 59, .07);
    --shadow-lift: 0 2px 4px rgba(23, 35, 59, .05), 0 18px 40px rgba(38, 44, 110, .14);
    --ease: cubic-bezier(.2, .75, .25, 1);
    --sidebar: 266px;

    --i-home: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='7' height='9' rx='1.5'/%3E%3Crect x='14' y='3' width='7' height='5' rx='1.5'/%3E%3Crect x='14' y='12' width='7' height='9' rx='1.5'/%3E%3Crect x='3' y='16' width='7' height='5' rx='1.5'/%3E%3C/svg%3E");
    --i-layers: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2 2 7l10 5 10-5-10-5z'/%3E%3Cpath d='m2 17 10 5 10-5'/%3E%3Cpath d='m2 12 10 5 10-5'/%3E%3C/svg%3E");
    --i-box: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 8 12 3 3 8v8l9 5 9-5z'/%3E%3Cpath d='m3 8 9 5 9-5'/%3E%3Cpath d='M12 13v8'/%3E%3C/svg%3E");
    --i-bed: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 4v16'/%3E%3Cpath d='M2 8h18a2 2 0 0 1 2 2v10'/%3E%3Cpath d='M2 17h20'/%3E%3Cpath d='M6 8v9'/%3E%3C/svg%3E");
    --i-factory: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 20h20'/%3E%3Cpath d='M4 20V10l6 4v-4l6 4V4h4v16'/%3E%3C/svg%3E");
    --i-chart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3v18h18'/%3E%3Cpath d='m7 15 4-4 3 3 5-6'/%3E%3C/svg%3E");
    --i-download: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12'/%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3Cpath d='M4 21h16'/%3E%3C/svg%3E");
    --i-users: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='4'/%3E%3Cpath d='M2 21c0-4 3-7 7-7s7 3 7 7'/%3E%3Cpath d='M16 4a4 4 0 0 1 0 8'/%3E%3Cpath d='M22 21c0-3-2-5.5-5-6.5'/%3E%3C/svg%3E");
    --i-shield: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 4 6v6c0 5 3.4 8 8 9 4.6-1 8-4 8-9V6z'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E");
    --i-wallet: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='6' width='20' height='14' rx='2.5'/%3E%3Cpath d='M2 10h20'/%3E%3Cpath d='M16 15h2'/%3E%3C/svg%3E");
    --i-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 2 20h20z'/%3E%3Cpath d='M12 10v5'/%3E%3Cpath d='M12 18h.01'/%3E%3C/svg%3E");
    --i-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 7 7 7 4-4 7 7'/%3E%3Cpath d='M21 12v5h-5'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(900px 420px at 12% -8%, rgba(90, 72, 196, .10), transparent 70%),
        radial-gradient(800px 380px at 95% -10%, rgba(19, 82, 122, .10), transparent 70%),
        var(--ground);
    background-attachment: fixed;
    color: var(--ink);
    font: 15px/1.65 "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body:has(.topbar) { padding-inline-start: var(--sidebar); }

a { color: var(--brand); text-decoration: none; transition: color .2s; }
a:hover { color: var(--violet); }

h1 { font-size: 27px; font-weight: 700; line-height: 1.3; margin: 0; letter-spacing: -.2px; }

h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 600;
    margin: 0 0 14px;
}

h2::before {
    content: "";
    width: 5px;
    height: 20px;
    border-radius: 3px;
    background: var(--accent);
}

/* Page loading line */
body::after {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    height: 3px;
    z-index: 60;
    background: linear-gradient(90deg, var(--violet), #38bdf8, var(--violet));
    background-size: 200% 100%;
    transform: scaleX(0);
    transform-origin: right;
    pointer-events: none;
}

body.leaving::after { animation: load 1.4s var(--ease) forwards, slide 1s linear infinite; }

/* Sidebar */
.topbar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: var(--sidebar);
    padding: 20px 14px 14px;
    overflow: hidden auto;
    color: #dbe3f6;
    background:
        radial-gradient(260px 200px at 85% 8%, rgba(120, 99, 235, .35), transparent 70%),
        radial-gradient(240px 260px at 10% 92%, rgba(56, 189, 248, .14), transparent 70%),
        linear-gradient(172deg, var(--night), var(--night-mid) 58%, var(--night-end));
    box-shadow: -6px 0 28px rgba(11, 23, 54, .18);
    view-transition-name: sidebar;
}

.topbar::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(1.2px 1.2px at 20px 30px, #fff, transparent),
        radial-gradient(1px 1px at 80px 120px, #fff, transparent),
        radial-gradient(1.4px 1.4px at 160px 60px, #fff, transparent),
        radial-gradient(1px 1px at 210px 190px, #fff, transparent),
        radial-gradient(1px 1px at 120px 240px, #fff, transparent),
        radial-gradient(1.2px 1.2px at 40px 320px, #fff, transparent);
    background-size: 266px 360px;
    opacity: .5;
    animation: twinkle 5s ease-in-out infinite;
}

.topbar > * { position: relative; }

.topbar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 8px 16px;
    margin-bottom: 4px;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .2px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.topbar .brand:hover { color: #fff; }

.topbar .logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    padding: 3px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
    transition: transform .5s var(--ease);
}

.topbar .brand:hover .logo { transform: rotate(-6deg) scale(1.06); }

.topbar nav { display: flex; flex: 1; flex-direction: column; gap: 3px; }

.topbar nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 13px;
    border-radius: 12px;
    color: rgba(226, 233, 248, .78);
    font-weight: 500;
    transition: background .25s, color .25s, transform .25s var(--ease);
}

.topbar nav a::before {
    content: "";
    flex: none;
    width: 20px;
    height: 20px;
    background: currentColor;
    mask: var(--icon) center / contain no-repeat;
    -webkit-mask: var(--icon) center / contain no-repeat;
    transition: transform .3s var(--ease);
}

.topbar nav a[href="/"] { --icon: var(--i-home); }
.topbar nav a[href="/Materials"] { --icon: var(--i-layers); }
.topbar nav a[href="/Stock/Documents"] { --icon: var(--i-box); }
.topbar nav a[href="/Products"] { --icon: var(--i-bed); }
.topbar nav a[href="/Production"] { --icon: var(--i-factory); }
.topbar nav a[href="/Reports"] { --icon: var(--i-chart); }
.topbar nav a[href="/Roles"] { --icon: var(--i-shield); }
.topbar nav a[href="/Export"] { --icon: var(--i-download); }
.topbar nav a[href="/Users"] { --icon: var(--i-users); }

.topbar nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); transform: translateX(-4px); }
.topbar nav a:hover::before { transform: scale(1.14); }

.topbar nav a.active {
    color: #fff;
    background: linear-gradient(120deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .07));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), 0 8px 20px rgba(0, 0, 0, .18);
}

.topbar nav a.active::after {
    content: "";
    position: absolute;
    inset-block: 9px;
    inset-inline-start: -14px;
    width: 4px;
    border-radius: 4px 0 0 4px;
    background: linear-gradient(#a79bff, #38bdf8);
}

.who {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 13px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .07);
}

.who a { color: #fff; min-width: 0; }
.who b { display: block; font-weight: 600; line-height: 1.3; }
.who small { display: block; color: #aebbdc; font-size: 12px; }
.who form { margin: 0; }
.who button.link { color: #b9c5e4; }
.who button.link:hover { color: #fff; filter: none; transform: none; }

/* Content */
main { max-width: 1760px; margin: 0 auto; padding: 22px 24px 40px; }

main > * { animation: rise .55s var(--ease) both; }
main > :nth-child(2) { animation-delay: .05s; }
main > :nth-child(3) { animation-delay: .1s; }
main > :nth-child(4) { animation-delay: .15s; }
main > :nth-child(5) { animation-delay: .2s; }
main > :nth-child(n + 6) { animation-delay: .25s; }

.head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 20px;
}

.head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.card {
    background: var(--paper);
    border: 1px solid rgba(230, 235, 243, .8);
    border-radius: 18px;
    padding: 16px 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    transition: box-shadow .35s, transform .35s var(--ease);
}

.card:hover { box-shadow: var(--shadow-lift); }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
    animation: none;
}

.stats.six { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat {
    --tone: var(--brand);
    --tint: var(--brand-soft);
    position: relative;
    overflow: hidden;
    padding: 18px 20px;
    border: 1px solid rgba(230, 235, 243, .8);
    border-radius: 18px;
    background: var(--paper);
    box-shadow: var(--shadow);
    animation: rise .6s var(--ease) both;
    transition: transform .35s var(--ease), box-shadow .35s;
}

.stat:nth-child(2) { --tone: var(--violet); --tint: #ece9fb; animation-delay: .07s; }
.stat:nth-child(3) { --tone: var(--warn); --tint: var(--warn-soft); animation-delay: .14s; }
.stat:nth-child(4) { --tone: var(--bad); --tint: var(--bad-soft); animation-delay: .21s; }
.stat:nth-child(5) { --tone: var(--good); --tint: var(--good-soft); animation-delay: .28s; }
.stat:nth-child(6) { --tone: var(--brand); --tint: var(--brand-soft); animation-delay: .35s; }

.stat::after {
    content: "";
    position: absolute;
    inset-block-start: -46px;
    inset-inline-end: -46px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: var(--tint);
    opacity: .75;
    transition: transform .6s var(--ease);
}

.stat:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.stat:hover::after { transform: scale(1.35); }

.stat .label { position: relative; z-index: 1; color: var(--muted); font-size: 13.5px; font-weight: 500; }

.stat .value {
    position: relative;
    z-index: 1;
    margin-top: 6px;
    color: var(--ink);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
}

.stat::before {
    content: "";
    position: absolute;
    z-index: 1;
    inset-block-start: 16px;
    inset-inline-end: 16px;
    width: 26px;
    height: 26px;
    background: var(--tone);
    mask: var(--icon, none) center / contain no-repeat;
    -webkit-mask: var(--icon, none) center / contain no-repeat;
}

.stat[data-i="wallet"] { --icon: var(--i-wallet); }
.stat[data-i="layers"] { --icon: var(--i-layers); }
.stat[data-i="alert"] { --icon: var(--i-alert); }
.stat[data-i="down"] { --icon: var(--i-down); }
.stat[data-i="box"] { --icon: var(--i-box); }
.stat[data-i="bed"] { --icon: var(--i-bed); }
.stat[data-i="factory"] { --icon: var(--i-factory); }
.stat[data-i="chart"] { --icon: var(--i-chart); }
.stat:not([data-i])::before { display: none; }

.stat.danger .value { color: var(--bad); }

.scroll { overflow-x: auto; }

table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 9px 11px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }

th {
    position: sticky;
    top: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    background: #f6f8fc;
    border-bottom: 0;
}

th:first-child { border-start-start-radius: 10px; border-end-start-radius: 10px; }
th:last-child { border-start-end-radius: 10px; border-end-end-radius: 10px; }

tbody tr { animation: row .45s var(--ease) both; transition: background .2s; }
tbody tr:nth-child(2) { animation-delay: .04s; }
tbody tr:nth-child(3) { animation-delay: .08s; }
tbody tr:nth-child(4) { animation-delay: .12s; }
tbody tr:nth-child(5) { animation-delay: .16s; }
tbody tr:nth-child(n + 6) { animation-delay: .2s; }
tbody tr:hover { background: #f5f7fd; }
tbody tr:last-child td { border-bottom: 0; }

td.wrap, th.wrap { white-space: normal; min-width: 170px; }
td.num, th.num { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; background: #f6f8fc; }

.up { color: var(--bad); font-weight: 500; }
.down { color: var(--good); font-weight: 500; }
.muted { color: var(--muted); }

.badge {
    display: inline-block;
    padding: 1px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: #eef1f7;
    color: var(--muted);
}

a.badge { margin: 0 0 6px 4px; transition: background .2s, color .2s; }
a.badge:hover { background: var(--brand-soft); color: var(--brand); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.good { background: var(--good-soft); color: var(--good); }

.notice {
    padding: 11px 16px;
    border-radius: 12px;
    border-inline-start: 4px solid transparent;
    margin: 0 0 16px;
    font-weight: 500;
    transition: opacity .4s, transform .4s var(--ease), max-height .4s, margin .4s, padding .4s;
}

.notice.ok { background: var(--good-soft); color: var(--good); border-color: var(--good); }
.notice.bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.notice.gone { opacity: 0; transform: translateY(-8px); max-height: 0; margin: 0; padding-block: 0; overflow: hidden; }
.notice ul { margin: 4px 0 0; padding-inline-start: 18px; font-weight: 400; }

label { display: block; font-size: 13.5px; font-weight: 500; color: #4c5a72; margin-bottom: 5px; }

input, select, textarea {
    width: 100%;
    padding: 9px 12px;
    font: inherit;
    color: var(--ink);
    background: #f8fafd;
    border: 1px solid #d9e0ec;
    border-radius: 10px;
    transition: border-color .2s, box-shadow .2s, background .2s;
}

input:hover, select:hover, textarea:hover { border-color: #b9c4d8; }

input:focus, select:focus, textarea:focus {
    outline: 0;
    background: #fff;
    border-color: var(--violet);
    box-shadow: 0 0 0 4px rgba(90, 72, 196, .14);
}

input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--violet); }
input[type="file"] { padding: 7px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: 14px; }

button, .btn {
    position: relative;
    display: inline-block;
    overflow: hidden;
    padding: 9px 20px;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(52, 62, 160, .24);
    transition: transform .22s var(--ease), box-shadow .22s, filter .22s;
}

button::after, .btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .38) 50%, transparent 70%);
    transform: translateX(120%);
    transition: transform .65s var(--ease);
}

button:hover, .btn:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 12px 24px rgba(52, 62, 160, .3); }
button:hover::after, .btn:hover::after { transform: translateX(-120%); }
button:active, .btn:active { transform: translateY(0) scale(.98); }
button:disabled { opacity: .65; cursor: progress; transform: none; }

.btn.light, button.light {
    color: var(--brand);
    background: var(--paper);
    box-shadow: inset 0 0 0 1px #d4dcea;
}

.btn.light:hover, button.light:hover {
    color: var(--violet);
    background: #f6f5ff;
    box-shadow: inset 0 0 0 1px var(--violet), 0 8px 16px rgba(52, 62, 160, .12);
}

.btn.light.current {
    color: #fff;
    background: var(--accent);
    box-shadow: 0 8px 18px rgba(52, 62, 160, .24);
}

.btn.danger, button.danger { color: var(--bad); background: var(--paper); box-shadow: inset 0 0 0 1px var(--bad); }
.btn.danger:hover, button.danger:hover { color: #fff; background: var(--bad); }

button.link { background: none; border: 0; box-shadow: none; color: var(--brand); padding: 0; font-weight: 500; overflow: visible; }
button.link::after { display: none; }
button.mini { padding: 3px 12px; font-size: 13px; font-weight: 500; border-radius: 8px; }

.lines td { padding: 7px 6px; }
.lines input, .lines select { min-width: 100px; }

/* First run steps */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }

.step {
    display: block;
    padding: 18px;
    border-radius: 16px;
    color: var(--ink);
    background: linear-gradient(160deg, #f7f8fe, #f1f3fd);
    border: 1px solid var(--line);
    transition: transform .3s var(--ease), box-shadow .3s, border-color .3s;
}

.step:hover { color: var(--ink); transform: translateY(-4px); border-color: #c9c4f3; box-shadow: var(--shadow-lift); }
.step b { display: block; margin-bottom: 3px; font-weight: 600; }
.step span { color: var(--muted); font-size: 14px; }

.step i {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-bottom: 10px;
    border-radius: 11px;
    color: #fff;
    font-style: normal;
    font-weight: 700;
    background: var(--accent);
}

/* Sign-in: a night sky around the card */
body:not(:has(.topbar)) {
    background:
        radial-gradient(520px 520px at 82% 14%, rgba(126, 105, 240, .5), transparent 70%),
        radial-gradient(620px 460px at 12% 88%, rgba(56, 189, 248, .22), transparent 70%),
        linear-gradient(160deg, var(--night), var(--night-mid) 55%, var(--night-end));
}

body:not(:has(.topbar))::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(1.6px 1.6px at 40px 60px, #fff, transparent),
        radial-gradient(1.2px 1.2px at 130px 180px, #fff, transparent),
        radial-gradient(1.8px 1.8px at 260px 90px, #fff, transparent),
        radial-gradient(1px 1px at 330px 260px, #fff, transparent),
        radial-gradient(1.4px 1.4px at 420px 150px, #fff, transparent),
        radial-gradient(1.2px 1.2px at 520px 300px, #fff, transparent),
        radial-gradient(1.6px 1.6px at 90px 330px, #fff, transparent);
    background-size: 560px 380px;
    animation: twinkle 4.5s ease-in-out infinite;
}

main.center {
    position: relative;
    z-index: 1;
    display: grid;
    align-content: center;
    max-width: 430px;
    min-height: 100vh;
    padding: 24px 16px;
}

main.center > * { animation: pop .75s var(--ease) both; }

main.center .card {
    margin: 0;
    padding: 30px 30px 32px;
    border: 1px solid rgba(255, 255, 255, .5);
    border-radius: 24px;
    background: rgba(255, 255, 255, .95);
    box-shadow: 0 30px 80px rgba(5, 10, 40, .5);
    backdrop-filter: blur(10px);
}

main.center button { width: 100%; padding-block: 11px; }

.login-logo {
    display: block;
    height: 138px;
    width: auto;
    margin: 0 auto 8px;
    animation: float 6s ease-in-out infinite;
}

.login-logo + .brand { display: none; }
h1.brand { display: block; font-size: 25px; color: var(--brand); }

@keyframes rise {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: none; }
}

@keyframes row {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: none; }
}

@keyframes pop {
    from { opacity: 0; transform: translateY(26px) scale(.96); }
    to { opacity: 1; transform: none; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes twinkle {
    0%, 100% { opacity: .85; }
    50% { opacity: .35; }
}

@keyframes load {
    from { transform: scaleX(0); }
    to { transform: scaleX(.92); }
}

@keyframes slide {
    to { background-position: -200% 0; }
}

::view-transition-old(root),
::view-transition-new(root) { animation-duration: .18s; }

/* Page layout pieces */
.columns { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.columns.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.nowrap { white-space: nowrap; }
td.ltr { text-align: right; }

.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.more { display: inline-block; margin-top: 10px; font-weight: 500; }
.empty { margin: 4px 0; padding: 18px 14px; border: 1px dashed #d3dbe8; border-radius: 12px; color: var(--muted); text-align: center; }

.tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: #eef1f8; }
.tabs a { padding: 3px 14px; border-radius: 8px; color: var(--muted); font-size: 13.5px; font-weight: 500; transition: background .2s, color .2s; }
.tabs a.on { color: #fff; background: var(--accent); box-shadow: 0 4px 10px rgba(52, 62, 160, .22); }

.list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 6px; border-bottom: 1px solid var(--line); transition: background .2s; }
.list li:last-child { border-bottom: 0; }
.list li:hover { background: #f7f8fd; }

.bars { display: grid; gap: 11px; }
.bar { display: block; color: var(--ink); }
.bar:hover { color: var(--brand); }
.bar-label { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; font-size: 13.5px; }
.bar-label b { font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-track { display: block; height: 8px; overflow: hidden; border-radius: 6px; background: #edf0f7; }
.bar-track i { display: block; width: var(--w); height: 100%; border-radius: 6px; background: var(--accent); animation: grow 1s var(--ease) both; transform-origin: right; }

/* Filters and paging */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
    border: 1px solid rgba(230, 235, 243, .8);
    border-radius: 14px;
    background: var(--paper);
    box-shadow: var(--shadow-sm);
}

.filters.flat { padding: 0; margin-bottom: 12px; border: 0; background: none; box-shadow: none; }
.filters > div { flex: 0 1 165px; min-width: 130px; }
.filters > .grow { flex: 1 1 240px; }
.filters label { margin-bottom: 3px; font-size: 12.5px; }
.filters input, .filters select { padding-block: 7px; }
.filters button, .filters .btn { padding-block: 8px; }

th a { display: inline-block; color: inherit; }
th a:hover { color: var(--violet); }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 13.5px; }
.sizes, .pages { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 3px; }
.sizes a, .pages a { min-width: 32px; padding: 3px 9px; border-radius: 8px; color: var(--muted); text-align: center; transition: background .2s, color .2s; }
.sizes a:hover, .pages a:hover { background: #eef1f8; color: var(--brand); }
.sizes a.on, .pages a.on { color: #fff; background: var(--accent); }

/* Row actions */
td.row-actions { width: 44px; padding-block: 4px; text-align: center; }
.menu { position: relative; display: inline-block; }
.menu summary { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: var(--muted); font-size: 19px; font-weight: 700; line-height: 1; list-style: none; cursor: pointer; transition: background .2s, color .2s; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover, .menu[open] summary { background: var(--brand-soft); color: var(--brand); }
.menu-list { position: fixed; z-index: 50; min-width: 190px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow-lift); text-align: right; animation: rise .2s var(--ease) both; }
.menu-list a, .menu-list .plain { display: block; width: 100%; padding: 7px 11px; border-radius: 8px; color: var(--ink); font: inherit; font-size: 14px; font-weight: 400; text-align: right; background: none; box-shadow: none; }
.menu-list a:hover, .menu-list .plain:hover { color: var(--brand); background: var(--brand-soft); transform: none; box-shadow: none; }
.menu-list .plain::after { display: none; }
.menu-list a.danger { color: var(--bad); }
.menu-list a.danger:hover { background: var(--bad-soft); color: var(--bad); }
.menu-list form { margin: 0; }

/* Reports and roles */
.group-title { margin: 18px 0 10px; }
.group-title:first-of-type { margin-top: 0; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-bottom: 8px; }

.report-card, .role-card {
    display: block;
    padding: 15px 17px;
    border: 1px solid rgba(230, 235, 243, .8);
    border-radius: 16px;
    color: var(--ink);
    background: var(--paper);
    box-shadow: var(--shadow);
    animation: rise .5s var(--ease) both;
    transition: transform .3s var(--ease), box-shadow .3s;
}

.report-card:hover { color: var(--ink); transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.report-card b { display: block; margin-bottom: 3px; font-weight: 600; }
.report-card span { color: var(--muted); font-size: 13.5px; }

.role-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 16px; }
.role-head b { font-weight: 600; }
.role-card p { min-height: 46px; margin: 4px 0 8px; font-size: 13.5px; }
.role-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.role-actions .btn, .role-actions button { padding: 4px 13px; font-size: 13.5px; }
.role-actions form { margin: 0; }
.meter { height: 6px; margin-bottom: 4px; overflow: hidden; border-radius: 4px; background: #edf0f7; }
.meter i { display: block; width: var(--w); height: 100%; background: var(--accent); animation: grow .9s var(--ease) both; transform-origin: right; }

.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; margin-bottom: 14px; }
.perm-group { display: grid; gap: 7px; align-content: start; min-width: 0; margin: 0; padding: 14px 16px; }
.perm-group legend { float: left; width: 100%; padding: 0 0 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.perm-group legend .check { font-size: 15px; font-weight: 600; }
.perm-group .check { margin: 0; cursor: pointer; }

.live-total { display: inline-block; padding: 5px 14px; border-radius: 10px; color: var(--brand); font-weight: 600; background: var(--brand-soft); }

@keyframes grow {
    from { transform: scaleX(0); }
    to { transform: none; }
}

@media (max-width: 1180px) {
    .columns, .columns.even { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
    body:has(.topbar) { padding-inline-start: 0; padding-bottom: 76px; }

    .topbar {
        position: sticky;
        inset: 0 0 auto;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: auto;
        padding: 10px 16px;
        overflow: visible;
    }

    .topbar .brand { padding: 0; margin: 0; font-size: 17px; border: 0; }
    .topbar .logo { width: 36px; height: 36px; border-radius: 10px; }
    .who { padding: 0; background: none; font-size: 14px; }

    .topbar nav {
        position: fixed;
        inset: auto 0 0;
        z-index: 40;
        flex-direction: row;
        gap: 2px;
        padding: 6px 8px;
        overflow-x: auto;
        background: linear-gradient(120deg, var(--night), var(--night-end));
        box-shadow: 0 -6px 20px rgba(11, 23, 54, .25);
    }

    .topbar nav a {
        flex: none;
        flex-direction: column;
        gap: 2px;
        min-width: 72px;
        padding: 6px 8px;
        font-size: 12px;
    }

    .topbar nav a:hover { transform: none; }
    .topbar nav a.active::after { display: none; }

    main { padding: 16px 16px 26px; }
    h1 { font-size: 22px; }
    .head .actions { width: 100%; }
    .head .actions .btn, .head .actions button { flex: 1 1 auto; text-align: center; }
    .stats, .stats.six { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .stat { padding: 14px; }
    .stat .value { font-size: 21px; }
    .stat::before { width: 20px; height: 20px; inset-block-start: 12px; inset-inline-end: 12px; }
    .card { padding: 14px; border-radius: 16px; }
    .filters > div, .filters > .grow { flex: 1 1 100%; }
    .filters button, .filters .btn { flex: 1 1 40%; text-align: center; }
    .who small { display: none; }
}

/* On a phone each table row becomes a labelled card. */
@media (max-width: 720px) {
    table:not(.lines) thead { display: none; }
    table:not(.lines), table:not(.lines) tbody { display: block; }

    table:not(.lines) tr {
        display: block;
        margin-bottom: 10px;
        padding: 6px 10px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: #fff;
    }

    table:not(.lines) td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        min-height: 34px;
        padding: 5px 2px;
        white-space: normal;
        text-align: left;
        border-bottom: 1px solid #f0f2f7;
    }

    table:not(.lines) td:last-child { border-bottom: 0; }
    table:not(.lines) td::before { content: attr(data-label); flex: none; max-width: 48%; color: var(--muted); font-size: 13px; font-weight: 500; text-align: right; }
    table:not(.lines) td[data-label=""]::before { display: none; }
    table:not(.lines) td:empty { display: none; }
    td.num { direction: rtl; }
    td.row-actions { width: auto; justify-content: flex-end; }
    tr.total td { background: none; }
    .lines input, .lines select { min-width: 78px; }
    .pager { justify-content: center; text-align: center; }
    .bar-label { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}

@media print {
    body:has(.topbar) { padding: 0; }
    .topbar, .actions, .filters, .pager, .row-actions, form { display: none; }
    main { padding: 0; max-width: none; }
    table thead { display: table-header-group; }
    body { background: #fff; }
    .card, .stat { box-shadow: none; }
    main > *, tbody tr { animation: none; }
}
