/* =====================================================
   AUTOMOTO TSL - Global styles
   Paleta: czerń (#0f0f0f), pomarańcz (#d9a227), kremowy off-white (#faf9f6)
===================================================== */

:root {
    --color-bg:       #faf9f6;
    --color-surface:  #ffffff;
    --color-ink:      #0f0f0f;
    --color-muted:    #6b6a65;
    --color-line:     #e6e4dc;
    --color-accent:   #d9a227;
    --color-accent-d: #b8851a;
    --color-accent-l: #fef3d4;
    --color-good:     #2d8659;
    --color-bad:      #c1352e;
    --color-warn:     #c97a14;
    
    --shadow-sm: 0 1px 2px rgba(15,15,15,0.06);
    --shadow-md: 0 4px 14px -2px rgba(15,15,15,0.08);
    
    --radius: 6px;
    --radius-lg: 10px;
    
    --font-display: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-body:    'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:    'Geist Mono', 'JetBrains Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--color-bg);
    color: var(--color-ink);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-ink);
    text-decoration: none;
    transition: color 0.15s;
}
a:hover { color: var(--color-accent-d); }

/* ===== HEADER ===== */
.app-header {
    background: var(--color-ink);
    color: #fff;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-header .brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.app-header .brand img { height: 55px; }
.app-header .brand .name {
    font-weight: 700;
    letter-spacing: 0.4px;
    font-size: 15px;
}
.app-header .brand .name .accent { color: var(--color-accent); }

.app-nav {
    display: flex;
    gap: 4px;
}
.app-nav a {
    color: #d0d0d0;
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}
.app-nav a:hover {
    color: #fff;
    background: rgba(255,255,255,0.07);
}
.app-nav a.active {
    color: #0f0f0f;
    background: var(--color-accent);
}

/* ===== LAYOUT ===== */
.app-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 24px 60px;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-line);
}
.page-head h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.3px;
}
.page-head .actions { display: flex; gap: 10px; }

/* ===== CARDS / BOXES ===== */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}
.card h2, .card h3 {
    margin: 0 0 14px 0;
    font-weight: 600;
}
.card h2 { font-size: 17px; }
.card h3 { font-size: 14px; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
@media (max-width: 900px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ===== FORMS ===== */
.field {
    margin-bottom: 14px;
}
.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--color-muted);
    margin-bottom: 5px;
}
.field input,
.field textarea,
.field select {
    width: 100%;
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
    padding: 8px 11px;
    font-family: inherit;
    font-size: 14px;
    color: var(--color-ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(217, 162, 39, 0.15);
}
.field textarea { min-height: 70px; resize: vertical; }

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.field-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.required::after {
    content: ' *';
    color: var(--color-bad);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--color-line);
    background: var(--color-surface);
    color: var(--color-ink);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.btn:hover {
    border-color: var(--color-ink);
    background: #f5f4ef;
}
.btn.primary {
    background: var(--color-ink);
    color: #fff;
    border-color: var(--color-ink);
}
.btn.primary:hover {
    background: var(--color-accent-d);
    border-color: var(--color-accent-d);
}
.btn.accent {
    background: var(--color-accent);
    color: var(--color-ink);
    border-color: var(--color-accent);
}
.btn.accent:hover {
    background: var(--color-accent-d);
    color: #fff;
}
.btn.danger {
    color: var(--color-bad);
    border-color: var(--color-line);
}
.btn.danger:hover {
    background: var(--color-bad);
    color: #fff;
    border-color: var(--color-bad);
}
.btn.sm { padding: 5px 11px; font-size: 12px; }
.btn.lg { padding: 11px 22px; font-size: 15px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ===== TABLES ===== */
.table-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
table.data-table {
    width: 100%;
    border-collapse: collapse;
}
table.data-table th {
    background: #f5f4ef;
    text-align: left;
    padding: 11px 14px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-muted);
    border-bottom: 1px solid var(--color-line);
}
table.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--color-line);
    font-size: 13.5px;
    vertical-align: top;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: #faf9f6; }
table.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ===== TAGS / BADGES ===== */
.tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f0eee5;
    color: var(--color-muted);
}
.tag.szkic    { background: #fdf2c0; color: #7a5a08; }
.tag.wyslane  { background: #d8eed8; color: #1e5d38; }
.tag.anulowane{ background: #f3d8d6; color: #862421; }
.tag.anulowane_oplacone { background: #862421; color: #fff; font-weight: 700; }

/* ===== AUTOCOMPLETE ===== */
.autocomplete-wrap {
    position: relative;
}
.autocomplete-dropdown {
    position: absolute;
    left: 0; right: 0; top: 100%;
    background: #fff;
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    margin-top: 4px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 50;
}
.autocomplete-dropdown .item {
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-line);
    font-size: 13px;
}
.autocomplete-dropdown .item:last-child { border-bottom: none; }
.autocomplete-dropdown .item:hover,
.autocomplete-dropdown .item.active { background: var(--color-accent-l); }
.autocomplete-dropdown .item .nazwa { font-weight: 600; }
.autocomplete-dropdown .item .meta  { font-size: 11.5px; color: var(--color-muted); margin-top: 2px; }
.autocomplete-dropdown .item .nip   { font-family: var(--font-mono); }
.autocomplete-dropdown .empty {
    padding: 12px;
    text-align: center;
    color: var(--color-muted);
    font-size: 13px;
}

/* ===== MODAL ===== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15,15,15,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    max-width: 920px;
    width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 60px -10px rgba(0,0,0,0.3);
}
.modal-head {
    padding: 16px 22px;
    border-bottom: 1px solid var(--color-line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
}
.modal-foot {
    padding: 14px 22px;
    border-top: 1px solid var(--color-line);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== HINTS, NOTES ===== */
.hint {
    font-size: 12px;
    color: var(--color-muted);
    margin-top: 3px;
}
.box-info {
    background: var(--color-accent-l);
    border-left: 3px solid var(--color-accent);
    padding: 10px 14px;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 13px;
    margin: 14px 0;
}
.box-info strong { color: var(--color-accent-d); }

/* ===== STATS ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
}
.stat-card .label {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-muted);
    margin-bottom: 6px;
}
.stat-card .val {
    font-size: 26px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}
.stat-card .val .unit { font-size: 14px; color: var(--color-muted); font-weight: 500; }
.stat-card.accent .val { color: var(--color-accent-d); }
.stat-card .sub { font-size: 12px; color: var(--color-muted); margin-top: 3px; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-muted);
}
.empty-state h3 { color: var(--color-ink); margin-bottom: 8px; }

/* ===== UTILITY ===== */
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.mb-3 { margin-bottom: 24px !important; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--color-muted); }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-1 { flex: 1; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-bad { color: var(--color-bad); }
.text-good { color: var(--color-good); }
.nowrap { white-space: nowrap; }
