/* Flussi Portal · sky theme */
:root {
  --bg: #ffffff;
  --panel: #f3f9fe;          /* very light sky */
  --side: #e6f3fc;           /* sidebar light blue */
  --side-on: #cfe8fa;
  --ink: #0f2a43;            /* deep navy text */
  --muted: #5b7088;
  --line: #dbe9f5;
  --blue: #1677d2;           /* primary */
  --blue-dark: #0e5aa6;
  --sky: #3fb4f0;            /* akashi */
  --sky-soft: #e3f4fd;
  --amber: #e2a11a;
  --red: #d9473f;
  --green: #1f9d6b;
  --violet: #6d5bd0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 42, 67, .04), 0 4px 16px rgba(22, 119, 210, .06);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", sans-serif;
  background: var(--bg); color: var(--ink);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0; letter-spacing: -0.02em; font-weight: 750; }
h1 small { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 6px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
small, .small { font-size: 13px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13.5px; letter-spacing: .02em; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ok-text { color: var(--green); }
.err-text { color: var(--red); }
.hide { display: none !important; }

/* ---------- layout ---------- */
body.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.main { padding: 28px 34px 60px; max-width: 1320px; width: 100%; }
body.bare .main { max-width: none; padding: 0; }

.side-nav {
  background: linear-gradient(180deg, #eaf5fd 0%, #e1f0fb 100%);
  border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 14px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 750; font-size: 16px; padding: 4px 8px 10px; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--sky), var(--blue)); color: #fff; font-weight: 800; font-size: 17px;
  box-shadow: 0 4px 12px rgba(22,119,210,.3);
}
.side-nav nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-nav nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
  color: #29506f; font-weight: 550; font-size: 14.5px; position: relative;
}
.side-nav nav a:hover { background: rgba(255,255,255,.7); text-decoration: none; }
.side-nav nav a.on { background: #fff; color: var(--blue); box-shadow: var(--shadow); }
.ic { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7b93ab; font-weight: 700; padding: 16px 12px 6px; }
.badge {
  margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center;
}
.me { display: flex; align-items: center; gap: 10px; padding: 12px; background: rgba(255,255,255,.75); border-radius: 12px; font-size: 13.5px; }
.me small { display: block; color: var(--muted); font-size: 12px; }
.me form { margin-left: auto; }
.me .link { font-size: 12.5px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--sky-soft); color: var(--blue); display: grid; place-items: center; font-weight: 700; flex: none; }

.mobile-bar { display: none; }
@media (max-width: 900px) {
  body.app { display: block; }
  .side-nav { position: fixed; z-index: 30; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  .side-nav.open { transform: none; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--side); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .mobile-bar .brand { padding: 0; flex: 1; }
  .burger { border: 0; background: #fff; border-radius: 10px; width: 40px; height: 40px; font-size: 20px; color: var(--blue); }
  .bell { position: relative; color: var(--ink); display: flex; }
  .bell .badge { position: absolute; top: -6px; right: -8px; }
  .main { padding: 18px 14px 50px; }
}

/* ---------- page header ---------- */
.head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section { margin: 28px 0 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 12px; letter-spacing: .08em; }

/* ---------- cards ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow-x: auto; }
.card.soft { background: var(--panel); box-shadow: none; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 8px; gap: 10px; }
.card-head h3 { margin: 0; }
.narrow { max-width: 820px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .cols, .cols2 { grid-template-columns: 1fr; } }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 8px; }
.kpi {
  border-radius: var(--radius); padding: 16px 18px; background: #fff; border: 1px solid var(--line);
  box-shadow: var(--shadow); display: block; color: var(--ink); position: relative; overflow: hidden;
}
a.kpi:hover { text-decoration: none; border-color: #b9daf3; }
.kpi .lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 30px; font-weight: 780; letter-spacing: -0.03em; margin-top: 4px; }
.kpi .sub { font-size: 12.5px; color: var(--muted); }
.kpi.hero { background: linear-gradient(135deg, #1677d2 0%, #3fb4f0 100%); color: #fff; border: 0; }
.kpi.hero .lbl, .kpi.hero .sub { color: rgba(255,255,255,.85); }
.kpi.alert { border-color: #f5d28a; background: #fffaf0; }
.kpi.alert .val { color: #b37800; }

.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat.dim { opacity: .5; }
.stat-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stat-num { font-size: 28px; font-weight: 760; margin: 6px 0 10px; letter-spacing: -0.03em; }
.stat-num small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

/* bars */
.bar { height: 8px; background: #e7f1fa; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--sky), var(--blue)); border-radius: 99px; }
.bar.warn span { background: linear-gradient(90deg, #f5c04a, var(--amber)); }
.bar.full span { background: linear-gradient(90deg, #f08079, var(--red)); }
.seat { display: flex; align-items: center; gap: 10px; }
.seat .bar { flex: 1; min-width: 70px; }
.seat > span { font-size: 13px; color: var(--muted); white-space: nowrap; min-width: 52px; text-align: right; }

/* donut + pipeline */
.pipeline { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pipe { padding: 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); }
.pipe:hover { text-decoration: none; border-color: #b9daf3; }
.pipe b { display: block; font-size: 24px; letter-spacing: -0.02em; }
@media (max-width: 800px) { .pipeline { grid-template-columns: repeat(3, 1fr); } }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 11px 14px; border-bottom: 1px solid var(--line); background: #f8fbfe; white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid #edf3f9; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fcff; }
tr.dim { opacity: .5; }
.empty { padding: 30px; color: var(--muted); text-align: center; }
table.edit input, table.edit select { padding: 7px 9px; font-size: 14px; margin: 0; }
table.edit input.num { width: 84px; }
tr.add td { background: var(--panel); }
.who { display: flex; flex-direction: column; }
.who small { color: var(--muted); }

/* pills */
.pill { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 650; background: #eef3f8; color: #3a5570; white-space: nowrap; }
.pill.spid { background: #e9e6fb; color: #4a3cb3; font-family: var(--mono); }
.pill.err { background: #fde8e6; color: var(--red); }
.pill.warn { background: #fff3d6; color: #946300; }
.pill.ok { background: #dcf5ea; color: #157a52; }
.pill.blue { background: var(--sky-soft); color: var(--blue-dark); }
.cat-agriculture { background: #e1f5e8; color: #1f7a45; }
.cat-agritourist { background: #fff1d9; color: #9a6200; }
.cat-sponsor { background: #e3effc; color: #1b5fa8; }
.role-admin { background: #e3effc; color: #1b5fa8; }
.role-employee { background: #e9e6fb; color: #4a3cb3; }
.role-agent { background: #e1f5f6; color: #0f7480; }
.status { font-size: 13px; font-weight: 650; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #a9b8c7; }
.st-uploaded::before { background: #a9b8c7; }
.st-verified::before { background: var(--sky); }
.st-submitted::before { background: var(--blue); }
.st-nulla_osta::before { background: var(--violet); }
.st-visa::before { background: var(--green); }
.st-rejected { color: var(--red); }
.st-rejected::before { background: var(--red); }

.kv { list-style: none; padding: 0; margin: 0; }
.kv li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); gap: 10px; }
.kv li:last-child { border: 0; }
.kv li span { color: var(--muted); }
.log { list-style: none; padding: 0; margin: 0; font-size: 13px; max-height: 320px; overflow: auto; }
.log li { padding: 8px 0; border-bottom: 1px dashed var(--line); }

/* docs */
.docs { display: grid; gap: 8px; }
.doc { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.doc .ficon { width: 38px; height: 38px; border-radius: 10px; background: var(--sky-soft); color: var(--blue); display: grid; place-items: center; font-weight: 800; font-size: 11px; flex: none; }
.doc.ricevuta { border-color: #b7dcf6; background: #f4faff; }
.doc .grow { flex: 1; min-width: 0; }
.doc .grow small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* messages */
.thread { display: grid; gap: 12px; }
.msg { padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); max-width: 85%; }
.msg.mine { margin-left: auto; background: var(--sky-soft); border-color: #c4e3f7; }
.msg small { display: block; color: var(--muted); margin-bottom: 4px; }
.msg p { margin: 0; white-space: pre-wrap; }

.notif { display: flex; gap: 12px; padding: 14px 18px; border-bottom: 1px solid #edf3f9; color: var(--ink); }
.notif:hover { background: #f8fcff; text-decoration: none; }
.notif .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); margin-top: 7px; flex: none; }
.notif.read .dot { background: transparent; }
.notif.read { color: var(--muted); }
.notif small { display: block; color: var(--muted); }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 650; color: #29445e; }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 10px 12px; font: inherit; font-weight: 400; color: var(--ink);
  border: 1px solid #cfe0ef; border-radius: 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 3px solid #d6ecfb; border-color: var(--sky); }
input[type=checkbox], input[type=radio] { width: auto; margin: 0; accent-color: var(--blue); }
.stack { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 700px) { .row2, .row3, .row4 { grid-template-columns: 1fr; } }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: 13px; font-weight: 650; margin-bottom: 8px; color: #29445e; }
.step { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; margin: 6px 0 2px; }
.step i { font-style: normal; width: 26px; height: 26px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 13px; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 700px) { .choices { grid-template-columns: 1fr; } }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 12px; padding: 13px; cursor: pointer; font-weight: 400; background: #fff; }
.choice span { display: flex; flex-direction: column; }
.choice small { color: var(--muted); }
.choice:has(input:checked) { border-color: var(--blue); background: var(--sky-soft); }
.choice.off { opacity: .45; cursor: not-allowed; }
.choice.wide { margin-bottom: 10px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.drop { border: 2px dashed #a9d3f1; border-radius: 14px; padding: 26px; text-align: center; cursor: pointer; font-weight: 400; background: var(--panel); display: block; }
.drop:hover, .drop.has { border-color: var(--blue); background: var(--sky-soft); }
.drop input { display: none; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px; }
.filters input, .filters select { width: auto; margin: 0; flex: 1 1 140px; }
form.inline { display: inline; }
.help { font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 4px; }
.box { padding: 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 10px; padding: 10px 18px;
  background: var(--blue); color: #fff; font: inherit; font-weight: 650; cursor: pointer; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(22,119,210,.25);
}
.btn:hover { background: var(--blue-dark); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: #fff; color: var(--blue); border: 1.5px solid #b9daf3; box-shadow: none; }
.btn.ghost:hover { background: var(--sky-soft); }
.btn.sky { background: var(--sky); }
.btn.ok { background: var(--green); box-shadow: none; }
.btn.danger { background: var(--red); box-shadow: none; }
.btn.big { padding: 13px 22px; font-size: 16px; }
.link { background: none; border: 0; padding: 0; color: var(--blue); font: inherit; cursor: pointer; }
.link.danger { color: var(--red); }
.danger-zone { border-color: #f6d2cf; }

.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 550; }
.flash.ok { background: #e6f6ee; color: #146444; border: 1px solid #bfe8d3; }
.flash.err { background: #fde8e6; color: #93231c; border: 1px solid #f6c7c2; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art {
  background: linear-gradient(150deg, #0e5aa6 0%, #1677d2 45%, #3fb4f0 100%); color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.login-art::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; right: -160px; bottom: -200px; background: rgba(255,255,255,.08); }
.login-art h2 { font-size: 38px; line-height: 1.15; margin: 0 0 14px; letter-spacing: -0.02em; max-width: 440px; }
.login-art p { opacity: .9; max-width: 420px; }
.login-art .brand { color: #fff; }
.login-art .brand .mark { background: #fff; color: var(--blue); }
.roles-strip { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.roles-strip span { background: rgba(255,255,255,.16); padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.login-form { display: grid; place-items: center; padding: 30px; background: #fff; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { margin-bottom: 6px; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-art { padding: 30px; min-height: 220px; } .login-art h2 { font-size: 26px; } }
@media (max-width: 700px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi.hero { grid-column: span 2; }
  .kpi .val { font-size: 24px; }
}

/* ---------- users page ---------- */
.users-layout { display: grid; grid-template-columns: minmax(380px, 520px) 1fr; gap: 22px; align-items: start; }
@media (max-width: 1100px) { .users-layout { grid-template-columns: 1fr; } }
.role-pick { display: grid; gap: 8px; }
.role-pick .choice { align-items: center; }
.user-list { display: grid; gap: 10px; }
.user-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.user-card.on { border-color: var(--sky); background: #f6fbff; }
.user-card.dim { opacity: .55; }
.user-card .grow { flex: 1; min-width: 0; }
.user-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15.5px; }
.user-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: #3a5570; margin-top: 4px; }
.avatar.big { width: 44px; height: 44px; font-size: 18px; }

/* roomier inline tables (cities, SPID) */
table.edit input { min-width: 90px; }
table.edit td:first-child input { min-width: 180px; }

/* v2.1 */
.pill.pri { background: #fff4d1; color: #9a6a00; }
.pri-box { border-style: dashed; }
.pri-box:has(input:checked) { border-color: #e2a11a; background: #fffaf0; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 70px; }
.pw-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-38%); border: 0; background: var(--sky-soft); color: var(--blue); font: inherit; font-size: 13px; font-weight: 650; padding: 5px 10px; border-radius: 8px; cursor: pointer; }
.reject-form { display: flex; gap: 6px; margin-top: 6px; }
.reject-form input { margin: 0; padding: 6px 9px; font-size: 13px; }

/* v2.2 bulk + report */
.bulk-rows { display: grid; gap: 10px; }
.bulk-row { display: flex; gap: 14px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.bulk-row:has([name=priority_idx]:checked) { border-color: #f0c55a; background: #fffcf3; }
.bulk-row .sl { width: 30px; height: 30px; border-radius: 50%; background: var(--sky-soft); color: var(--blue); display: grid; place-items: center; font-weight: 700; flex: none; font-size: 13px; }
.bulk-fields { flex: 1; display: grid; gap: 8px; min-width: 0; }
.bulk-row .rm { font-size: 18px; padding: 4px 8px; }
@media print {
  .side-nav, .mobile-bar, .no-print, .flash { display: none !important; }
  body.app { display: block; }
  .main { padding: 0; max-width: none; }
  .card, .kpi, .stat { box-shadow: none; }
}
