:root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --ink: #1f2733;
    --muted: #6b7686;
    --line: #e4e8f0;
    --brand: #2f6df0;
    --brand-dark: #2257c9;
    --green: #1f9d57;
    --green-bg: #e4f6ec;
    --orange: #c97a14;
    --orange-bg: #fdf0dd;
    --gray-bg: #eef1f6;
    --red: #d23b3b;
    --red-bg: #fbe6e6;
    --blue: #2f6df0;
    --blue-bg: #e6effd;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(20, 30, 50, .06), 0 6px 24px rgba(20, 30, 50, .05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: 248px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--line);
}
.brand small { display: block; color: var(--muted); font-size: 12px; }
.brand-dot {
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, var(--brand), #5b93ff);
}

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; margin: 2px 0;
    border-radius: 8px; color: var(--ink); font-weight: 500;
}
.nav-item:hover { background: var(--gray-bg); text-decoration: none; }
.nav-item.active { background: var(--blue-bg); color: var(--brand-dark); }
.nav-ico { width: 20px; text-align: center; opacity: .8; }

.sidebar-foot {
    border-top: 1px solid var(--line);
    padding: 14px 18px;
    display: flex; align-items: center; justify-content: space-between;
}
.who { font-weight: 600; font-size: 13px; }
.logout { font-size: 13px; color: var(--muted); }

.main { flex: 1; padding: 28px 34px; max-width: 1200px; }

/* --- Headings / page header -------------------------------------------- */
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 2px; }

/* --- Cards / panels ----------------------------------------------------- */
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.card h2 { font-size: 16px; margin: 0 0 14px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 28px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }

/* --- Tables ------------------------------------------------------------- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #fafbfd; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfe; }
.cell-actions { white-space: nowrap; text-align: right; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* --- Badges ------------------------------------------------------------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-gray { background: var(--gray-bg); color: var(--muted); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--brand-dark); }

/* --- Buttons ------------------------------------------------------------ */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--panel); color: var(--ink); font-weight: 600; font-size: 14px;
    cursor: pointer; text-decoration: none; line-height: 1;
}
.btn:hover { text-decoration: none; background: #f7f9fc; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--red); border-color: #f0c9c9; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- Forms -------------------------------------------------------------- */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13.5px; }
.form-row .hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=datetime-local], input[type=search], input[type=url], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line);
    border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--blue-bg); }
textarea { resize: vertical; min-height: 90px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* --- Flash -------------------------------------------------------------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-error { background: var(--red-bg); color: var(--red); }
.flash-info { background: var(--blue-bg); color: var(--brand-dark); }
.flash-center { max-width: 420px; margin: 20px auto -4px; }

/* --- Toolbar / search --------------------------------------------------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.toolbar form { display: flex; gap: 8px; flex: 1; }

/* --- Login -------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 380px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 22px; }

/* --- Misc --------------------------------------------------------------- */
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { background: var(--gray-bg); padding: 4px 10px; border-radius: 6px; font-size: 13px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 16px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: none; }
.progress { height: 8px; background: var(--gray-bg); border-radius: 5px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--green); }
.placeholder-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip { background: var(--blue-bg); color: var(--brand-dark); border: none; padding: 5px 10px; border-radius: 6px; font-size: 12.5px; cursor: pointer; font-family: monospace; }
.public-wrap { max-width: 540px; margin: 60px auto; padding: 0 20px; }
