/* ZO Legal — Portal Klienta
   Aesthetic: luxury legal — champagne gold on charcoal, Cormorant Garamond
   display serif + Jost geometric sans, hairline gold rules, quiet grain. */

:root {
  --bg:        #0c0d10;
  --bg-1:      #111319;
  --bg-2:      #161922;
  --bg-3:      #1d212c;
  --line:      rgba(200, 169, 106, 0.16);
  --line-2:    rgba(255, 255, 255, 0.06);
  --gold:      #c8a96a;
  --gold-br:   #e6cd92;
  --gold-dp:   #9c7d44;
  --text:      #ece8e0;
  --text-dim:  #a39e94;
  --text-mute: #746f66;
  --ok:        #97c08a;
  --warn:      #e0b878;
  --danger:    #e0917f;

  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans:  "Jost", system-ui, -apple-system, sans-serif;

  --radius: 6px;
  --maxw: 1140px;
  --shadow: 0 18px 50px -28px rgba(0, 0, 0, 0.85);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 15.5px;
  line-height: 1.6;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* atmospheric gold glow */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1100px 520px at 78% -8%, rgba(200, 169, 106, 0.10), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(200, 169, 106, 0.05), transparent 55%);
  z-index: 0;
}

/* fine grain overlay */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

main, .topbar, .flashes { position: relative; z-index: 2; }

a { color: inherit; text-decoration: none; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.01em; margin: 0; }

em { font-style: italic; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 40px 28px 80px; }

.muted { color: var(--text-dim); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- eyebrow / typography accents ---------- */
.eyebrow {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.26em;
  color: var(--gold);
  font-weight: 500;
  margin: 0 0 10px;
}
.crumb { color: var(--text-mute); transition: color 0.2s; }
.crumb:hover { color: var(--gold); }

.page-title { font-size: 38px; line-height: 1.05; }
.display { font-size: clamp(40px, 5.5vw, 64px); line-height: 1.02; font-weight: 600; }
.lede { color: var(--text-dim); font-size: 16px; max-width: 44ch; }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 13, 16, 0.72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.04em;
  border-radius: 4px;
  background: linear-gradient(160deg, rgba(200,169,106,0.14), transparent);
}
.brand-mark.lg { width: 56px; height: 56px; font-size: 23px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: 0.16em; }
.brand-name.xl { font-size: 26px; }
.brand-tag { font-size: 10.5px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-mute); }

.nav { display: flex; gap: 24px; margin-left: auto; }
.nav a {
  font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-dim); padding: 6px 0; position: relative; transition: color 0.2s;
}
.nav a:hover { color: var(--text); }
.nav a.is-active { color: var(--gold); }
.nav a.is-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px; background: var(--gold);
}

.user-box { display: flex; align-items: center; gap: 12px; }
.user-chip {
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--gold); border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px;
}
.user-email { font-size: 13px; color: var(--text-dim); }
.logout { font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-mute); transition: color 0.2s; }
.logout:hover { color: var(--danger); }

/* ---------- page head ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  margin-bottom: 30px; padding-bottom: 22px; border-bottom: 1px solid var(--line-2);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 12px 22px; border-radius: 4px; border: 1px solid transparent;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.2s, background 0.2s, color 0.2s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-gold {
  background: linear-gradient(165deg, var(--gold-br), var(--gold) 55%, var(--gold-dp));
  color: #181307; border-color: var(--gold-dp);
  box-shadow: 0 12px 28px -16px rgba(200, 169, 106, 0.7);
}
.btn-gold:hover { box-shadow: 0 16px 34px -14px rgba(200, 169, 106, 0.85); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--gold); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--gold); background: rgba(200, 169, 106, 0.06); }
.btn-sm { padding: 9px 15px; font-size: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.link-gold { color: var(--gold); font-size: 13px; letter-spacing: 0.04em; transition: opacity 0.2s; }
.link-gold:hover { opacity: 0.78; }
.link-danger { color: var(--danger); font-size: 13px; letter-spacing: 0.04em; transition: opacity 0.2s; }
.link-danger:hover { opacity: 0.78; }
.as-button { background: none; border: none; cursor: pointer; font-family: var(--sans); padding: 0; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(224,145,127,0.4); }
.btn-danger:hover { border-color: var(--danger); background: rgba(224,145,127,0.08); }
.row-actions { display: flex; gap: 16px; justify-content: flex-end; align-items: center; }

/* ---------- panels / cards ---------- */
.panel {
  background: linear-gradient(180deg, var(--bg-1), rgba(17, 19, 25, 0.6));
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 26px 26px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.panel-flat {
  background: var(--bg-1); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 18px 22px;
}
.panel-title { font-size: 21px; margin-bottom: 16px; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-title-row .panel-title { margin-bottom: 0; }
.mt { margin-top: 18px; }

/* ---------- flashes ---------- */
.flashes {
  position: fixed; top: 18px; right: 18px; z-index: 60;
  display: flex; flex-direction: column; gap: 10px; max-width: 380px;
}
.flash {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  padding: 13px 15px; border-radius: 5px; box-shadow: var(--shadow);
  font-size: 14px; animation: slidein 0.35s ease;
}
.flash-success { border-left-color: var(--ok); }
.flash-error { border-left-color: var(--danger); }
.flash-x { background: none; border: none; color: var(--text-mute); cursor: pointer; font-size: 18px; line-height: 1; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-wide { max-width: 720px; }
.form-row { display: block; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label {
  font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); font-weight: 500;
}
.req { color: var(--gold); font-style: normal; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea, .select {
  font-family: var(--sans); font-size: 15px; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 4px;
  padding: 11px 13px; width: 100%; transition: border-color 0.2s, box-shadow 0.2s; resize: vertical;
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }
input:focus, textarea:focus, .select:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 169, 106, 0.16);
}
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%); background-position: calc(100% - 18px) center, calc(100% - 13px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.hint { font-size: 12.5px; color: var(--text-mute); }
.info {
  display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid var(--line); color: var(--gold); font-size: 9px; font-style: italic; cursor: help;
}
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 26px; }

/* ---------- auth ---------- */
body.auth { display: flex; }
.auth-wrap { width: 100%; max-width: none; margin: 0; padding: 0; min-height: 100vh; }
.auth-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; min-height: 100vh; }
.auth-aside {
  padding: 56px 64px; display: flex; flex-direction: column; justify-content: space-between;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(700px 420px at 20% 10%, rgba(200, 169, 106, 0.10), transparent 60%),
    linear-gradient(180deg, #0a0b0e, #0e1014);
}
.auth-aside-top { display: flex; align-items: center; gap: 16px; }
.auth-aside-mid { margin: 40px 0; }
.auth-aside-mid .display em { color: var(--gold); }
.auth-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-points li { display: flex; align-items: center; gap: 12px; color: var(--text-dim); font-size: 14px; }
.auth-points .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px rgba(200,169,106,0.7); }

.auth-panel { display: grid; place-items: center; padding: 40px; background: var(--bg); }
.auth-form-card { width: 100%; max-width: 380px; }
.auth-h2 { font-size: 34px; margin: 4px 0 6px; }
.auth-form-card .form { margin-top: 26px; }
.auth-foot { margin-top: 22px; font-size: 13px; }

/* ---------- case cards (client) ---------- */
.card-list { display: flex; flex-direction: column; gap: 14px; }
.case-card {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 22px 24px; background: var(--bg-1); border: 1px solid var(--line-2);
  border-radius: var(--radius); transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.case-card:hover { border-color: var(--line); transform: translateY(-2px); box-shadow: var(--shadow); }
.case-id { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); margin-bottom: 5px; }
.case-title { font-size: 22px; }
.case-sub { color: var(--text-dim); font-size: 13.5px; margin: 5px 0 0; }
.case-card-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 9px; text-align: right; }
.meta-line { font-size: 12.5px; color: var(--text-mute); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 500;
  padding: 5px 11px; border-radius: 999px; border: 1px solid transparent;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.st-new      { color: #cdb988; background: rgba(200,169,106,0.10); border-color: rgba(200,169,106,0.25); }
.st-draft    { color: #9b9890; background: rgba(255,255,255,0.05); border-color: var(--line-2); }
.st-approved { color: #8ab6c9; background: rgba(138,182,201,0.10); border-color: rgba(138,182,201,0.28); }
.st-review   { color: var(--warn); background: rgba(224,184,120,0.10); border-color: rgba(224,184,120,0.25); }
.st-done     { color: var(--ok); background: rgba(151,192,138,0.10); border-color: rgba(151,192,138,0.25); }
.st-closed   { color: #9b9890; background: rgba(255,255,255,0.05); border-color: var(--line-2); }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 80px 24px; }
.empty-mark { font-family: var(--serif); font-size: 72px; color: var(--gold); opacity: 0.5; line-height: 1; margin-bottom: 12px; }
.empty h3 { font-size: 26px; margin-bottom: 8px; }
.empty .btn { margin-top: 20px; }

/* ---------- stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat {
  background: var(--bg-1); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 22px;
  position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; top: 0; left: 0; width: 36px; height: 2px; background: var(--gold); }
.stat-num { display: block; font-family: var(--serif); font-size: 42px; font-weight: 600; line-height: 1; color: var(--text); }
.stat-lbl { display: block; margin-top: 8px; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  text-align: left; font-family: var(--sans); font-weight: 500; font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-mute);
  padding: 0 14px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table tbody td { padding: 15px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table tbody tr:hover { background: rgba(200, 169, 106, 0.03); }
.t-title { color: var(--text); font-size: 14.5px; }
.t-sub { color: var(--text-mute); font-size: 12.5px; margin-top: 2px; }
.t-actions { text-align: right; white-space: nowrap; }
.row-off { opacity: 0.5; }

/* ---------- detail layout ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
.detail-side .panel { margin-bottom: 18px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 10px 14px; margin: 0; font-size: 14px; }
.kv dt { color: var(--text-mute); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; padding-top: 2px; }
.kv dd { margin: 0; color: var(--text); }
.kv dd.pre { white-space: pre-wrap; }

/* ---------- document list ---------- */
.doc-list { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; }
.doc-item {
  display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line-2);
}
.doc-item:last-child { border-bottom: none; }
.doc-ico {
  flex-shrink: 0; display: grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid var(--line-2); border-radius: 5px; font-size: 10px; letter-spacing: 0.08em;
  color: var(--text-dim); background: var(--bg-2);
}
.doc-ico.gold { color: var(--gold); border-color: var(--line); }
.doc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.doc-meta { color: var(--text-mute); font-size: 12.5px; white-space: nowrap; }
.doc-dl { color: var(--gold); font-size: 12.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.doc-dl:hover { text-decoration: underline; }

/* ---------- dropzone ---------- */
.dropzone {
  display: block; border: 1.5px dashed var(--line); border-radius: var(--radius);
  background: rgba(200, 169, 106, 0.025); padding: 34px 24px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s; text-align: center;
}
.dropzone:hover, .dropzone.drag { border-color: var(--gold); background: rgba(200, 169, 106, 0.07); }
.dropzone.compact { padding: 22px; margin-top: 18px; }
.dz-icon { font-size: 26px; color: var(--gold); margin-bottom: 8px; }
.dropzone-inner p { margin: 4px 0; }
.dz-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dz-list li { font-size: 13px; color: var(--text-dim); display: flex; gap: 8px; align-items: center; justify-content: center; }
.dz-list li::before { content: "•"; color: var(--gold); }
.inline-upload { margin-top: 8px; }
.inline-upload .btn { margin-top: 14px; }

/* ---------- notices ---------- */
.notice {
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; font-size: 14px;
  border: 1px solid var(--line-2); border-left: 3px solid var(--gold); background: var(--bg-1);
}
.notice-error { border-left-color: var(--danger); color: #f0c4ba; }
.notice-info { border-left-color: var(--gold); color: var(--text-dim); }

/* ---------- szablon generator ---------- */
.szablon-form { display: block; }
.szablon-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.faktura-row { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; background: var(--bg-2); }
.faktura-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.faktura-no { font-family: var(--serif); font-size: 17px; color: var(--gold); }
.faktura-del { background: none; border: none; color: var(--text-mute); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; transition: color 0.2s; }
.faktura-del:hover { color: var(--danger); }
.faktura-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.sticky-actions {
  position: sticky; bottom: 0; margin-top: 22px; padding: 16px 0;
  background: linear-gradient(180deg, transparent, var(--bg) 40%);
}

/* ---------- processing / progress ---------- */
.proc-panel { border-left: 3px solid var(--gold); }
.progress {
  margin-top: 18px; height: 6px; border-radius: 999px; overflow: hidden;
  background: rgba(255, 255, 255, 0.06); position: relative;
}
.progress-bar {
  position: absolute; top: 0; left: 0; height: 100%; width: 38%; border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--gold-br), var(--gold), transparent);
  animation: indeterminate 1.4s ease-in-out infinite;
}
@keyframes indeterminate {
  0% { left: -40%; }
  100% { left: 100%; }
}

/* ---------- summary totals ---------- */
.sum-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.sum-item {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.sum-item::after { content: ""; position: absolute; top: 0; left: 0; width: 28px; height: 2px; background: var(--gold); }
.sum-lbl { display: block; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-mute); }
.sum-val { display: block; margin-top: 8px; font-family: var(--serif); font-size: 25px; font-weight: 600; color: var(--text); line-height: 1.1; }
.sum-words { margin-top: 16px; font-size: 14px; }
.count-pill {
  font-family: var(--sans); font-size: 12px; font-weight: 400; color: var(--gold);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; margin-left: 8px; vertical-align: middle;
}
.recompute-form { margin-top: 14px; }

/* ---------- approve + danger zone ---------- */
.approve-panel {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  border-left: 3px solid var(--gold);
}
.approve-panel .btn { font-size: 14px; padding: 14px 30px; letter-spacing: 0.12em; }
.danger-zone { border: 1px solid rgba(224,145,127,0.25); }
.danger-zone .panel-title { color: var(--danger); }

/* ---------- pozew download row (admin) ---------- */
.pozew-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.pozew-meta { display: flex; align-items: center; gap: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .sum-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-grid { grid-template-columns: 1fr; }
  .auth-aside { border-right: none; border-bottom: 1px solid var(--line); padding: 40px 32px; }
  .faktura-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 14px; }
  .nav { order: 3; width: 100%; margin-left: 0; }
  .user-box { margin-left: auto; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-title { font-size: 30px; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .sum-grid { grid-template-columns: 1fr; }
  .faktura-grid { grid-template-columns: 1fr; }
  .container { padding: 28px 18px 60px; }
}
