/* ── Hanami Design System ─────────────────────────────────────────────
   Brand: #283430 moss ink · #D98AA4 sakura pink · #E5C98B sunlight gold
   Layout: light paper sidebar (220px) + warm off-white content area
   ──────────────────────────────────────────────────────────────────── */

@import url('https://api.fontshare.com/v2/css?f[]=satoshi@400,500,600,700&display=swap');

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Brand tokens ── */
:root {
    /* Canvas */
    --bg:                  #FAF7F5;
    --surface:             rgba(255,255,255,0.80);
    --surface-2:           #EAEFEC;

    /* Sidebar — light, paper-like */
    --sidebar-bg:          #F4F1EE;
    --sidebar-border:      rgba(40,52,48,0.07);
    --sidebar-text:        rgba(40,52,48,0.52);
    --sidebar-text-active: #283430;
    --sidebar-hover:       rgba(217,138,164,0.08);
    --sidebar-active-bg:   rgba(217,138,164,0.14);

    /* Borders */
    --border:              rgba(40,52,48,0.09);
    --border-strong:       rgba(40,52,48,0.18);

    /* Text */
    --text:                #283430;
    --text-muted:          #7A9088;
    --text-faint:          #A8B8AE;

    /* Accent — sakura pink */
    --accent:              #D98AA4;
    --accent-dim:          rgba(217,138,164,0.12);
    --accent-soft:         #E8B7C8;
    --amber:               #E5C98B;
    --amber-dim:           rgba(229,201,139,0.15);

    /* Semantic */
    --green:               #5A8A72;
    --green-dim:           rgba(90,138,114,0.12);
    --teal:                #5A8A72;
    --red:                 #C0392B;
    --red-dim:             rgba(192,57,43,0.10);
    /* Decyzja — „czeka na twoją decyzję" (język kolorów §3, UX-WIZJA). NIE alarm. */
    --blue:                #3D6E8F;
    --blue-dim:            rgba(61,110,143,0.12);
    --sage:                #A8B8AE;

    /* Layout */
    --sidebar-w:           220px;
    --radius:              12px;
    --font:                'Satoshi', 'Inter', system-ui, sans-serif;

    /* Shadows — ultra soft */
    --shadow-sm:           0 1px 4px rgba(40,52,48,0.05), 0 0 1px rgba(40,52,48,0.06);
    --shadow-md:           0 4px 20px rgba(40,52,48,0.07), 0 1px 4px rgba(40,52,48,0.04);
}

/* ── Body ── */
body {
    font-family: var(--font);
    font-size: 14px;
    background: linear-gradient(180deg, #FAF7F5 0%, #F6F1F2 50%, #EEF2EE 100%);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.5;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ════════════════════════════════════════
   SIDEBAR — light paper
   ════════════════════════════════════════ */

.app-sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 2px 0 16px rgba(40,52,48,0.04);
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Logo */
.sidebar-logo {
    display: flex;
    align-items: center;
    padding: 18px 18px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    text-decoration: none !important;
}
.sidebar-logo:hover { opacity: 0.80; text-decoration: none !important; }
.sidebar-logo-img {
    height: 30px;
    width: auto;
    display: block;
    /* no filter — logo is dark on light sidebar */
}

/* Section labels */
.sidebar-section {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-faint);
    padding: 18px 18px 5px;
}

/* Nav links */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    margin: 1px 6px;
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    transition: color 0.15s, background 0.15s;
    text-decoration: none !important;
}
.sidebar-link:hover {
    color: var(--sidebar-text-active);
    background: var(--sidebar-hover);
    text-decoration: none !important;
}
.sidebar-link.active {
    color: var(--accent);
    background: var(--sidebar-active-bg);
    border-color: rgba(217,138,164,0.18);
}
.sidebar-link svg {
    width: 16px; height: 16px;
    flex-shrink: 0;
    opacity: 0.55;
}
.sidebar-link.active svg,
.sidebar-link:hover svg { opacity: 1; }

/* Alert badge in sidebar */
.sidebar-badge {
    margin-left: auto;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 6px;
    line-height: 1.5;
}

/* Sidebar footer */
.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--sidebar-border);
    padding: 14px 18px;
    font-size: 12px;
    color: var(--text-faint);
}
.sidebar-footer .org-name {
    color: var(--accent);
    font-weight: 600;
    font-size: 12px;
    display: block;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-footer .user-email {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
    font-size: 11px;
    color: var(--text-muted);
}
.sidebar-footer a { color: var(--text-faint); font-size: 12px; }
.sidebar-footer a:hover { color: var(--text-muted); text-decoration: none; }

/* ════════════════════════════════════════
   MAIN CONTENT
   ════════════════════════════════════════ */

.container {
    margin-left: var(--sidebar-w);
    padding: 28px 32px;
    min-height: 100vh;
}
.container--narrow { max-width: 860px; }

/* Auth pages: no sidebar */
.container.no-sidebar {
    margin-left: 0;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

/* ── Page header ── */
.page-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.page-header h1 { font-size: 20px; font-weight: 600; color: var(--text); }
h1 { font-size: 20px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
h2 { font-size: 16px; font-weight: 600; color: var(--text); }
h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

/* ── KPI tiles ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.kpi-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(12px);
}
.kpi-tile__label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.kpi-tile__value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.02em;
}
.kpi-tile__unit {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}
.kpi-tile__sub {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 4px;
}
.kpi-tile--accent .kpi-tile__value { color: var(--accent); }
.kpi-tile--green  .kpi-tile__value { color: var(--green); }

/* ── Badges / status pills ── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-green    { background: var(--green-dim);  color: var(--green); }
.badge-amber    { background: var(--amber-dim);  color: #9B6B1A; }
.badge-red      { background: var(--red-dim);    color: var(--red); }
.badge-gray     { background: rgba(40,52,48,0.07); color: var(--text-muted); }
.badge-muted    { background: rgba(40,52,48,0.07); color: var(--text-muted); }
.badge-sage     { background: rgba(168,184,174,0.20); color: #4A7060; }
.badge-pink     { background: var(--accent-dim); color: var(--accent); }
.badge-blue     { background: var(--blue-dim); color: var(--blue); }

/* Status badges */
.status-ok          { background: var(--green-dim); color: var(--green);     font-size:11px; font-weight:600; padding:2px 8px; border-radius:10px; }
.status-decision    { background: var(--blue-dim);  color: var(--blue);      font-size:11px; font-weight:600; padding:2px 8px; border-radius:10px; }
.status-warning     { background: var(--amber-dim); color: #9B6B1A;          font-size:11px; font-weight:600; padding:2px 8px; border-radius:10px; }
.status-error       { background: var(--red-dim);   color: var(--red);       font-size:11px; font-weight:600; padding:2px 8px; border-radius:10px; }
.status-missing     { background: rgba(40,52,48,0.07); color: var(--text-muted); font-size:11px; font-weight:600; padding:2px 8px; border-radius:10px; }
.status-simulation  { background: rgba(75,92,112,0.10); color: #4B5C70;      font-size:11px; font-weight:600; padding:2px 8px; border-radius:10px; }
.status-assumed     { background: var(--amber-dim); color: #9B6B1A;          font-size:11px; font-weight:600; padding:2px 8px; border-radius:10px; border:1px dashed rgba(229,201,139,0.5); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    font-size: 13px;
    text-align: left;
}
th {
    background: rgba(217,138,164,0.08);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}
td { color: var(--text); }
tr:hover td { background: rgba(217,138,164,0.04); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table--compact th, .table--compact td { padding: 5px 8px; font-size: 12px; }

/* ── Buttons ── */
.btn {
    display: inline-block;
    padding: 8px 18px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: var(--font);
    transition: opacity 0.15s, transform 0.15s, box-shadow 0.15s;
    text-decoration: none !important;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); text-decoration: none !important; }
.btn-primary {
    background: linear-gradient(135deg, #D98AA4, #E8B7C8);
    color: #fff;
    box-shadow: 0 2px 8px rgba(217,138,164,0.30);
}
.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(217,138,164,0.35);
}
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent-soft); }
.btn-danger {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(192,57,43,0.25);
}
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(217,138,164,0.12);
}
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.error-list { color: var(--red); font-size: 12px; margin-top: 4px; }
.help-text  { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(12px);
}
.card__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}
.card__value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}
.card-grid { display: grid; gap: 16px; }
.card-grid--2 { grid-template-columns: 1fr 1fr; }
.card-grid--3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Empty state ── */
.empty {
    color: var(--text-muted);
    text-align: center;
    padding: 48px 16px;
    font-size: 14px;
}
.empty p { margin-bottom: 16px; }

/* ── Progress bar ── */
.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, #D98AA4, #E8B7C8);
    border-radius: 3px;
    transition: width 0.3s;
}

/* ── Alert items ── */
.alert-item {
    border-left: 3px solid var(--border);
    padding: 12px 16px;
    margin-bottom: 8px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    font-size: 13px;
}
.alert-item__title { font-weight: 600; margin-bottom: 2px; }
.alert-item__meta  { font-size: 12px; color: var(--text-muted); }
.alert-item--critical { border-left-color: var(--red); }
.alert-item--critical .alert-item__title { color: var(--red); }
.alert-item--warning  { border-left-color: var(--amber); }
.alert-item--warning  .alert-item__title { color: #9B6B1A; }
.alert-item--info     { border-left-color: var(--accent-soft); }

/* ── Flash messages ── */
.messages { margin-bottom: 16px; }
.message {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 8px;
    border: 1px solid transparent;
}
.message-success { background: var(--green-dim); color: var(--green); border-color: rgba(90,138,114,0.2); }
.message-error   { background: var(--red-dim);   color: var(--red);   border-color: rgba(192,57,43,0.2); }
.message-warning { background: var(--amber-dim); color: #9B6B1A;      border-color: rgba(229,201,139,0.30); }
.message-info    { background: var(--accent-dim); color: var(--accent); border-color: rgba(217,138,164,0.20); }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Section title row ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.section-header h2 { font-size: 15px; font-weight: 600; }

/* ── Data row / label-value pairs ── */
.data-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.data-row:last-child { border-bottom: none; }
.data-row__label { color: var(--text-muted); }
.data-row__value { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Auth card ── */
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(20px);
}
.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}
.auth-logo img { height: 36px; width: auto; }
.auth-logo span {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.01em;
}

/* ── Workflow steps ── */
.step {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
}
.step-done    { border-left: 3px solid var(--green); }
.step-active  { border-left: 3px solid var(--accent); }
.step-running { border-left: 3px solid var(--amber); }
.step-locked  { opacity: 0.55; }
.step-error   { border-left: 3px solid var(--red); }
.step-header  { display: flex; justify-content: space-between; align-items: center; }
.step-header .status { font-size: 12px; font-weight: 600; }
.step-header .status-done   { color: var(--green); }
.step-header .status-error  { color: var(--red); }
.step-header .status-locked { color: var(--text-faint); }
.step-body { margin-top: 12px; }

/* ── Month nav ── */
.month-nav { display: flex; gap: 4px; margin-bottom: 24px; flex-wrap: wrap; }
.month-nav a, .month-nav span {
    padding: 5px 11px;
    border-radius: var(--radius);
    text-decoration: none !important;
    font-size: 13px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: var(--surface);
    transition: border-color 0.15s, color 0.15s;
}
.month-nav a:hover { border-color: var(--accent); color: var(--text); text-decoration: none !important; }
.month-nav .current { background: linear-gradient(135deg, #D98AA4, #E8B7C8); color: #fff; border-color: transparent; }
.month-nav .closed  { color: var(--green); border-color: rgba(90,138,114,0.25); background: var(--green-dim); }
.month-nav .error   { color: var(--red);   border-color: rgba(192,57,43,0.25); background: var(--red-dim); }
.month-nav .future  { opacity: 0.4; pointer-events: none; }

/* ── Confirm input ── */
.confirm-box { margin-top: 12px; }
.confirm-box input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    width: 260px;
    font-family: var(--font);
    font-size: 13px;
}
.confirm-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

/* ── Results table (settlement preview) ── */
.results-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.results-table th, .results-table td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    font-size: 12px;
    text-align: right;
}
.results-table th { background: rgba(217,138,164,0.08); text-align: left; font-weight: 600; color: var(--text-muted); }
.results-table td:first-child { text-align: left; }

/* ── Risk / data quality indicators ── */
.risk-missing   { color: var(--red);    font-weight: 600; }
.risk-assumed   { color: #9B6B1A;       font-weight: 600; }
.risk-simulated { color: #4B5C70;       font-weight: 600; }
.risk-ok        { color: var(--green);  font-weight: 600; }

/* ── Legacy ── */
.topbar { display: none; }
.nav    { display: none; }

@media print {
  .app-sidebar,
  .topbar,
  .nav-admin { display: none !important; }
  .container { margin-left: 0 !important; padding: 0 !important; }
  .er { padding: 0 !important; }
  .card { break-inside: avoid; }
  .section { break-before: auto; }
  [data-no-print] { display: none !important; }
}
