:root {
  --navy: #0b1f3a;
  --navy-2: #132a4d;
  --navy-3: #1a3a66;
  --yellow: #f5c518;
  --yellow-ink: #3a2d00;
  --green: #1b8a3a;
  --green-bg: #e5f6ea;
  --red: #c62828;
  --red-bg: #fdecea;
  --amber: #b45309;
  --amber-bg: #fff6d6;
  --ink: #152033;
  --muted: #5b6b80;
  --line: #d7dee8;
  --bg: #eef2f6;
  --card: #ffffff;
  --shadow: 0 8px 24px rgba(11, 31, 58, 0.08);
  --radius: 14px;
  --header-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: Verdana, Geneva, "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}
a { color: #154b9a; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .35rem; line-height: 1.25; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

/* ---- header ---- */
.app-header {
  background: linear-gradient(160deg, var(--navy) 0%, #16345f 100%);
  color: #fff;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.app-header .brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-header .titles small { display: block; color: #c9d6ea; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.app-header h1 { font-size: 17px; font-weight: 700; }
.app-header .userbox { text-align: right; font-size: 12px; color: #d7e2f3; }
.app-header .userbox strong { display: block; color: #fff; font-size: 13px; }
.app-header .userbox button {
  background: none; border: 0; color: #ffd0d0; padding: 4px 0 0; font-size: 12px; text-decoration: underline;
}

.mark {
  width: 36px; height: 36px; border-radius: 9px; background: var(--yellow); color: var(--navy);
  display: grid; place-items: center; font-weight: 700; font-size: 11px; letter-spacing: .02em; flex-shrink: 0;
}

main { padding: 14px 14px calc(28px + var(--safe-bottom)); max-width: 1100px; margin: 0 auto; }

/* ---- login ---- */
.login-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 20% -10%, #1d4e89, var(--navy));
}
.login-card {
  width: min(420px, 100%); background: #fff; border-radius: 18px; padding: 28px 22px;
  box-shadow: var(--shadow);
}
.login-card .mark { margin-bottom: 14px; width: 48px; height: 48px; font-size: 14px; }
.login-card h1 { font-size: 22px; color: var(--navy); }
.login-card p.lead { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.login-card label { margin-top: 10px; }

/* ---- kpis ---- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.kpi {
  background: var(--card); border-radius: 12px; padding: 10px 8px; text-align: center;
  border: 1px solid #edf1f6; box-shadow: var(--shadow); cursor: pointer;
}
.kpi .value { font-size: 22px; font-weight: 700; letter-spacing: -.03em; display: block; }
.kpi .label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.kpi.active { outline: 2px solid var(--navy); }
.kpi.overdue .value { color: var(--red); }
.kpi.open .value { color: var(--navy); }
.kpi.waiting .value { color: var(--amber); }
.kpi.done .value { color: var(--green); }

/* ---- toolbar ---- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: stretch; }
.toolbar input, .toolbar select { min-width: 0; flex: 1 1 140px; }
.toolbar input[type=search] { flex: 1 1 100%; }
.toolbar .btn { flex: 1 1 auto; }
@media (min-width: 860px) {
  .toolbar input[type=search] { flex: 1 1 220px; }
  .toolbar .btn { flex: 0 0 auto; }
}

input[type=text], input[type=password], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff;
  min-height: 44px;
}
textarea { min-height: 88px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.error { color: var(--red); font-size: 14px; margin: 8px 0; }
.empty { color: var(--muted); padding: 28px 8px; text-align: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 10px 14px; min-height: 44px;
  background: var(--navy); color: #fff; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #e6edf6; color: var(--navy); }
.btn.yellow { background: var(--yellow); color: var(--yellow-ink); }
.btn.danger { background: var(--red); color: #fff; }
.btn.success { background: var(--green); color: #fff; }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.btn.block { width: 100%; }

/* ---- badges ---- */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: #e8eef6; color: #274066; letter-spacing: .02em;
}
.badge.Open { background: #e0f2fe; color: #075985; }
.badge.Waiting { background: #fef3c7; color: #92400e; }
.badge.Overdue { background: var(--red-bg); color: #7f1d1d; }
.badge.Done { background: var(--green-bg); color: #14532d; }
.badge.High { background: var(--red-bg); color: #7f1d1d; }
.badge.Med { background: #ffedd5; color: #9a3412; }
.badge.Low { background: #e5e7eb; color: #374151; }

/* ---- cards (mobile list) ---- */
.card-list { display: grid; gap: 10px; }
.fu-card {
  display: block; width: 100%; text-align: left; background: var(--card);
  border: 1px solid #edf1f6; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px 12px 16px; position: relative; text-decoration: none; color: inherit;
  border-left: 5px solid var(--navy-3);
}
.fu-card.overdue { border-left-color: var(--red); background: #fff8f8; }
.fu-card.done { border-left-color: #9aa8bc; opacity: .9; }
.fu-card.waiting { border-left-color: #d4a017; }
.fu-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.fu-card .fu-id { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.fu-card h3 { font-size: 15px; margin: 4px 0 8px; color: var(--navy); }
.fu-card .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); }
.fu-card .due { font-weight: 700; color: var(--ink); }
.fu-card.overdue .due { color: var(--red); }

/* ---- desktop table ---- */
.table-wrap { display: none; overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid #edf1f6; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; background: #f7f9fc; }
tr.overdue { background: #fff5f5; }
tr.done { color: #5b6b80; }
tr:hover td { background: #f7fafc; }
tr { cursor: pointer; }
td.title-cell { font-weight: 700; color: var(--navy); }
td .sub { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 2px; }
.due-cell.overdue { color: var(--red); font-weight: 700; }

@media (min-width: 860px) {
  .card-list { display: none; }
  .table-wrap { display: block; }
  .kpis { gap: 12px; }
  .kpi .value { font-size: 28px; }
  .kpi .label { font-size: 11px; }
  main { padding: 20px 20px 40px; }
}

/* ---- detail / form ---- */
.page-title { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.page-title p { margin: 0; color: var(--muted); font-size: 13px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--navy); text-decoration: none; font-size: 13px; font-weight: 700; margin-bottom: 8px; }

.panel {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; border: 1px solid #edf1f6; margin-bottom: 14px;
}
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) {
  .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}
.span-2 { grid-column: 1 / -1; }

.notes { list-style: none; padding: 0; margin: 0; }
.notes li { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.notes li:last-child { border-bottom: 0; }
.notes time, .notes .who { color: var(--muted); font-size: 12px; }
.notes .who { font-weight: 700; margin-right: 8px; }
.notes .body { margin-top: 4px; white-space: pre-wrap; }

.flash { background: var(--green-bg); border: 1px solid #b7e3c3; color: #14532d; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.banner.danger { background: var(--red-bg); border: 1px solid #f3b4b0; color: #7f1d1d; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }

.muted { color: var(--muted); }
.hidden { display: none !important; }
