:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #1c2330; --muted: #5d6676; --line: #e1e4ea;
  --brand: #1f3a68; --brand-ink: #ffffff; --accent: #2f6fdb;
  --ok: #1d7a45; --ok-bg: #e6f4ec; --warn: #9a5b00; --warn-bg: #fff4e0;
  --err: #b42318; --err-bg: #fdecea; --chip: #eef1f6;
  --radius: 8px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 1rem; font-weight: 600; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 600; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
code, .mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: .86em; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: var(--brand-ink); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; }
.side .logo { font-weight: 700; font-size: 1.02rem; padding: .25rem .5rem 1rem; letter-spacing: .01em; }
.side .logo small { display: block; font-weight: 400; opacity: .7; font-size: .78rem; }
.side nav a { display: flex; justify-content: space-between; color: #dfe6f3; padding: .5rem .6rem; border-radius: 6px; margin-bottom: 2px; }
.side nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.side nav a.on { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.side .badge { background: #f5b301; color: #1c2330; border-radius: 10px; padding: 0 .45rem; font-size: .78rem; font-weight: 700; }
.side form { margin-top: 1.5rem; padding: 0 .5rem; }
.side form button { background: none; border: 1px solid rgba(255,255,255,.3); color: #dfe6f3; width: 100%; }
main { padding: 1.5rem 2rem 3rem; max-width: 1200px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stat .n { font-size: 1.7rem; font-weight: 700; } .stat .l { color: var(--muted); font-size: .85rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

.chip { display: inline-block; background: var(--chip); border-radius: 12px; padding: .05rem .55rem; font-size: .8rem; color: var(--ink); white-space: nowrap; }
.chip.share, .chip.sent, .chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.view, .chip.pending_approval, .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.deny, .chip.rejected, .chip.error, .chip.err { background: var(--err-bg); color: var(--err); }
.chip.ignored { background: var(--chip); color: var(--muted); }

.alert { border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: 1rem; border: 1px solid; }
.alert.ok { background: var(--ok-bg); border-color: #b5dfc5; color: var(--ok); }
.alert.err { background: var(--err-bg); border-color: #f4c0bb; color: var(--err); }
.alert.warn { background: var(--warn-bg); border-color: #f2d39b; color: var(--warn); }
ul.reasons { margin: .3rem 0 0; padding-left: 1.2rem; }

input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  font: inherit; padding: .5rem .6rem; border: 1px solid #c9ced8; border-radius: 6px; background: #fff; color: var(--ink); max-width: 100%; }
textarea { width: 100%; min-height: 220px; font-family: inherit; line-height: 1.5; }
textarea.short { min-height: 70px; }
label { font-size: .88rem; color: var(--muted); display: block; margin-bottom: .25rem; }
.field { margin-bottom: .8rem; }
button, .btn { font: inherit; border-radius: 6px; padding: .5rem .95rem; border: 1px solid #c9ced8; background: #fff; color: var(--ink); cursor: pointer; display: inline-block; }
button:hover, .btn:hover { background: #f2f4f8; text-decoration: none; }
.btn-primary { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #17633a; }
.btn-blue { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-blue:hover { background: #172d52; }
.btn-danger { color: var(--err); border-color: #f0b7b1; }
.btn-small { padding: .2rem .55rem; font-size: .82rem; }
form.inline { display: inline; }

.req-card { display: block; color: inherit; }
.req-card:hover { text-decoration: none; border-color: #b9c3d6; }
.mail { white-space: pre-wrap; background: #fafbfc; border: 1px solid var(--line); border-radius: 6px; padding: .8rem; font-size: .92rem; max-height: 320px; overflow: auto; }
.att { display: flex; gap: .6rem; align-items: flex-start; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.att:last-child { border-bottom: 0; }
.crumbs a { color: var(--muted); }
.tree a { display: flex; justify-content: space-between; padding: .35rem .2rem; border-bottom: 1px solid var(--line); color: var(--ink); }
.empty { color: var(--muted); padding: 1.5rem; text-align: center; }

.auth { max-width: 420px; margin: 8vh auto; }
.auth .panel { padding: 1.6rem; }
.auth h1 { text-align: center; }
.qr svg { display: block; margin: .5rem auto; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { display: flex; flex-wrap: wrap; gap: 4px; }
  main { padding: 1rem; }
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
}
