:root{
  --bg:#eceef2; --surface:#ffffff; --panel:#f6f8fb;
  --ink:#0e1a2b; --muted:#6b7789; --line:#dfe4ec;
  --accent:#1f4bd8; --accent-ink:#173aa8;
  --ok:#127a45; --ok-soft:#e4f4ea;
  --danger:#c02626; --amber:#b45309;
  --radius:12px; --shadow:0 1px 2px rgba(16,30,54,.06),0 8px 24px rgba(16,30,54,.06);
}
*{box-sizing:border-box}
html,body{margin:0}
body{
  font-family:"Inter",system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  background:var(--bg); color:var(--ink); font-size:14px; line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
h1,h2{font-family:"Space Grotesk","Inter",sans-serif; letter-spacing:-.01em; margin:0}
h1{font-size:1.5rem} h2{font-size:1.1rem}
a{color:var(--accent); text-decoration:none}
.muted{color:var(--muted)}
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:.86rem}

/* ------------------------------------------------------------------ topbar */
.topbar{
  display:flex; align-items:center; gap:24px;
  background:var(--ink); color:#eef2f8; padding:0 22px; height:58px;
  position:sticky; top:0; z-index:20;
}
.brand{display:flex; align-items:center; gap:9px; font-family:"Space Grotesk",sans-serif}
.brand-mark{color:#7aa2ff; font-size:1.3rem; line-height:1}
.brand-name{font-weight:600; letter-spacing:-.01em}
.brand-name span{color:#7aa2ff}
.topnav{display:flex; gap:4px; margin-left:8px}
.topnav a{
  color:#aeb8c8; padding:8px 12px; border-radius:8px; font-weight:500; font-size:.9rem;
}
.topnav a:hover{color:#fff; background:rgba(255,255,255,.06)}
.topnav a.active{color:#fff; background:rgba(122,162,255,.18)}
.who{display:flex; align-items:center; gap:12px; margin-left:auto}
.who-name{color:#c5cdda; font-size:.85rem}
.who-role{
  font-size:.68rem; text-transform:uppercase; letter-spacing:.06em; font-weight:700;
  padding:3px 8px; border-radius:999px;
}
.role-admin{background:#7aa2ff; color:#0e1a2b}
.role-provider{background:#2b3a52; color:#aec4ff}

/* ------------------------------------------------------------------ layout */
.wrap{max-width:920px; margin:0 auto; padding:28px 22px 60px}
.wrap.wide{max-width:1280px}
.page-head{display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:18px}

/* ------------------------------------------------------------------ buttons */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  font:inherit; font-weight:600; font-size:.9rem; cursor:pointer;
  border:1px solid transparent; border-radius:10px; padding:9px 16px; transition:.12s;
}
.btn-primary{background:var(--accent); color:#fff}
.btn-primary:hover{background:var(--accent-ink)}
.btn-ghost{background:transparent; border-color:var(--line); color:var(--ink)}
.btn-ghost:hover{background:var(--panel)}
.topbar .btn-ghost{color:#c5cdda; border-color:rgba(255,255,255,.18)}
.topbar .btn-ghost:hover{background:rgba(255,255,255,.08); color:#fff}
.btn-block{width:100%}
.link{background:none; border:none; color:var(--accent); font:inherit; font-weight:600; cursor:pointer; padding:0}
.link:hover{text-decoration:underline}
.link.danger{color:var(--danger)}

/* ------------------------------------------------------------------ flashes */
.flashes{margin-bottom:16px; display:grid; gap:8px}
.flash{padding:10px 14px; border-radius:10px; font-weight:500; border:1px solid}
.flash-error{background:#fdecec; border-color:#f5c2c2; color:#9a1c1c}
.flash-success{background:var(--ok-soft); border-color:#bfe3cd; color:#0f5c34}

/* ------------------------------------------------------------------ cards */
.card{background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); padding:22px}
.form-card{display:grid; gap:14px; max-width:560px}
.form-card.narrow{max-width:420px}
label{display:grid; gap:6px; font-weight:600; font-size:.85rem}
label small{color:var(--muted); font-weight:500}
input[type=text],input[type=password],input[type=number],input[type=search],input[type=file],select{
  font:inherit; padding:9px 11px; border:1px solid var(--line); border-radius:9px;
  background:#fff; color:var(--ink); width:100%;
}
input:focus,select:focus{outline:none; border-color:var(--accent); box-shadow:0 0 0 3px rgba(31,75,216,.15)}
.rule,.hint,.date{font-size:.8rem; color:var(--muted)}
.rule{margin:0}

/* ------------------------------------------------------------------ auth */
.auth-shell{min-height:100vh; display:grid; place-items:center; padding:24px;
  background:radial-gradient(1200px 600px at 20% -10%, #1c2b45 0%, #0e1a2b 55%)}
.auth-card{display:grid; grid-template-columns:1.05fr 1fr; width:min(860px,100%);
  background:var(--surface); border-radius:18px; overflow:hidden; box-shadow:0 30px 80px rgba(0,0,0,.4)}
.auth-side{background:linear-gradient(160deg,#16283f,#0e1a2b); color:#dbe6f7; padding:40px 36px; display:flex; flex-direction:column; gap:14px}
.auth-mark{font-size:2rem; color:#7aa2ff}
.auth-side h1{color:#fff; font-size:1.7rem}
.auth-side h1 span{color:#7aa2ff}
.auth-side p{color:#a9bad4; margin:0}
.auth-points{list-style:none; padding:0; margin:14px 0 0; display:grid; gap:10px}
.auth-points li{position:relative; padding-left:22px; color:#c6d3e7; font-size:.9rem}
.auth-points li::before{content:"✓"; position:absolute; left:0; color:#5ee0a0; font-weight:700}
.auth-form{padding:40px 36px; display:grid; align-content:center; gap:6px}
.auth-form h2{font-size:1.4rem}
.auth-form form{display:grid; gap:14px; margin-top:14px}

/* ------------------------------------------------------------------ add panel */
.add-panel{position:relative}
.add-panel > summary{list-style:none; cursor:pointer}
.add-panel > summary::-webkit-details-marker{display:none}
.add-form{
  position:absolute; right:0; top:calc(100% + 8px); width:min(680px,88vw);
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:var(--shadow); padding:20px; z-index:15; display:grid; gap:16px;
}
.add-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:14px}
.add-checks{display:flex; flex-wrap:wrap; gap:10px 18px; padding-top:2px}
.chk{display:inline-flex; align-items:center; gap:8px; font-weight:500; cursor:pointer}
.chk input{width:18px; height:18px; accent-color:var(--accent)}
.add-actions{display:flex; gap:10px; align-items:center}
.req::after{content:" *"; color:var(--danger)}

/* ------------------------------------------------------------------ toolbar */
.toolbar{display:flex; flex-wrap:wrap; gap:12px; align-items:center; justify-content:space-between; margin-bottom:14px}
.filters{display:flex; flex-wrap:wrap; gap:7px}
.pill{
  font-size:.82rem; font-weight:600; color:var(--muted);
  padding:6px 12px; border-radius:999px; border:1px solid var(--line); background:var(--surface);
}
.pill:hover{border-color:#c3ccda}
.pill.on{background:var(--ink); color:#fff; border-color:var(--ink)}
.toolbar-right{display:flex; gap:8px; align-items:center}
.toolbar-right select,.toolbar-right input{width:auto}

/* ------------------------------------------------------------------ grid table */
.table-scroll{overflow-x:auto; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); box-shadow:var(--shadow)}
table.grid{width:100%; border-collapse:collapse; min-width:820px}
.grid thead th{
  position:sticky; top:0; background:var(--panel); text-align:left;
  font-size:.72rem; text-transform:uppercase; letter-spacing:.05em; color:var(--muted);
  padding:11px 14px; border-bottom:1px solid var(--line); white-space:nowrap;
}
.grid tbody td{padding:9px 14px; border-bottom:1px solid var(--line); vertical-align:middle}
.grid tbody tr:last-child td{border-bottom:none}
.grid tbody tr:hover{background:#f9fbfe}
.grid .num{text-align:right; font-variant-numeric:tabular-nums}
.grid .center{text-align:center}
.col-photo{width:64px}
.col-photo img{width:46px; height:46px; object-fit:cover; border-radius:8px; border:1px solid var(--line); display:block}
.prov{font-weight:600}
.col-actions{white-space:nowrap; display:flex; gap:12px; align-items:center}
.col-actions form{display:inline}
.empty-row td{text-align:center; color:var(--muted); padding:34px}

/* checkmark toggle cell */
.check-toggle{
  display:inline-flex; align-items:center; justify-content:center;
  width:24px; height:24px; border-radius:7px; border:1px solid var(--line);
  background:#fff; cursor:pointer; transition:.12s; user-select:none;
}
.check-toggle:hover{border-color:#b7c0d0}
.check-toggle.checked{background:var(--ok-soft); border-color:#9ed3b4}
.check-toggle.checked::after{content:"✓"; color:var(--ok); font-weight:800; font-size:.95rem; line-height:1}

/* inline-editable numeric cell */
td.editable{cursor:pointer; position:relative}
td.editable:hover{background:#eef4ff; box-shadow:inset 0 0 0 1px #b9ccf6}
td.editable .cell-input{
  width:100%; padding:3px 6px; border:1px solid var(--accent); border-radius:6px;
  font:inherit; text-align:right; font-variant-numeric:tabular-nums;
  box-shadow:0 0 0 3px rgba(31,75,216,.15);
}

/* "Can't make" flag button */
.flag-toggle{
  font:inherit; font-size:.78rem; font-weight:600; cursor:pointer;
  padding:5px 10px; border-radius:999px; border:1px solid var(--line);
  background:#fff; color:var(--muted); white-space:nowrap; transition:.12s;
}
.flag-toggle:hover{border-color:#e2a3a3; color:var(--danger)}
.flag-toggle.on{background:#fdecec; border-color:#e7a9a9; color:#a01c1c}
.chk-flag span{color:var(--danger)}
.chk-flag input{accent-color:var(--danger)}

/* a locked row: dimmed, and its other cells cannot be interacted with */
tr.blocked td:not(.col-photo):not(.col-flag):not(:last-child){opacity:.4}
tr.blocked .check-toggle,
tr.blocked td.editable{pointer-events:none}
tr.blocked td.editable:hover{background:transparent; box-shadow:none}

/* status row tints (precedence: can't make > delivered > in production) */
tr.row-production{background:#fff3e0}
tr.row-production:hover{background:#ffe9cc}
tr.row-delivered{background:#e9f7ef}
tr.row-delivered:hover{background:#d9f0e2}
tr.blocked{background:#fdecec}
tr.blocked:hover{background:#f9dcdc}

/* ------------------------------------------------------------------ misc */
.two-col{display:grid; grid-template-columns:minmax(280px,420px) 1fr; gap:18px; align-items:start}
.grid.slim{min-width:0}
.grid.slim thead th,.grid.slim tbody td{padding:8px 10px}
.edit-photo{display:flex; gap:16px; align-items:flex-end; flex-wrap:wrap}
.edit-photo img{width:96px; height:96px; object-fit:cover; border-radius:10px; border:1px solid var(--line)}
.edit-photo label{flex:1; min-width:180px}
.error-card{max-width:460px; margin:60px auto; text-align:center}
.error-card h1{font-size:3rem; color:var(--accent)}
.hint{margin-top:12px}

@media (max-width:720px){
  .auth-card{grid-template-columns:1fr}
  .auth-side{display:none}
  .two-col{grid-template-columns:1fr}
  .who-name{display:none}
  .page-head{flex-direction:column}
}

/* ---- Lists page (manage dropdown options) ---- */
.lists-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:18px}
.add-option{display:flex; gap:8px; margin:4px 0 14px}
.add-option input{flex:1}
.option-list{list-style:none; padding:0; margin:0; display:grid; gap:2px}
.option-list li{display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:7px 10px; border:1px solid var(--line); border-radius:8px; background:var(--panel)}
.option-list li span{font-weight:500}
.option-list form{display:inline}

/* ---- inline dropdown edit in the table ---- */
td.attr-edit{cursor:pointer; position:relative}
td.attr-edit:hover{background:#eef4ff; box-shadow:inset 0 0 0 1px #b9ccf6}
td.attr-edit .attr-select{width:100%; min-width:110px; padding:4px 6px; border:1px solid var(--accent);
  border-radius:6px; font:inherit; box-shadow:0 0 0 3px rgba(31,75,216,.15)}
.tag{display:inline-block; max-width:160px; overflow:hidden; text-overflow:ellipsis;
  white-space:nowrap; vertical-align:bottom}
