/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #f5f3ef;
    --card: #ffffff;
    --accent: #2d6a4f;
    --accent-light: #40916c;
    --text: #1b1b1b;
    --muted: #6b7280;
    --border: #e0ddd9;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Header ─── */
header {
    background: #1f2937;
    color: #fff;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
}
header h1 { font-size: 1.25rem; font-weight: 700; }
.tagline { display: none; }
.header-link {
    color: #fff;
    text-decoration: none;
    font-size: .78rem;
    font-weight: 600;
    padding: 5px 10px;
    border: 1px solid rgba(255,255,255,.4);
    border-radius: 6px;
    transition: background .15s;
    white-space: nowrap;
}
.header-link:hover { background: rgba(255,255,255,.15); }
.header-link:last-child { margin-left: auto; }

@media (min-width: 700px) {
    header { padding: 20px 24px; gap: 12px; }
    header h1 { font-size: 1.5rem; }
    .tagline { display: inline; font-size: .85rem; opacity: .8; }
    .header-link { font-size: .85rem; padding: 6px 14px; }
    .header-link:last-child { margin-left: auto; }
}

/* ─── Main ─── */
main { flex: 1; max-width: 1200px; margin: 0 auto; padding: 16px; width: 100%; }
@media (min-width: 700px) { main { padding: 20px; } }

/* ─── Stats ─── */
.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}
@media (min-width: 500px) { .stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); } }
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-card .num { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.stat-card .label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* ─── Tabs ─── */
.tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 12px;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    padding: 8px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: .82rem;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* ─── Tables ─── */
.tab-content { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    font-size: .8rem;
}
.data-table th {
    background: #f1efeb;
    padding: 8px 8px;
    text-align: left;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: var(--muted);
    white-space: nowrap;
}
.data-table td {
    padding: 8px 8px;
    border-top: 1px solid var(--border);
    font-size: .8rem;
}
.data-table tbody tr:hover { background: #faf8f5; }
.data-table .clickable-row { cursor: pointer; }
.data-table .clickable-row:hover { background: #eeebe6 !important; }
.data-table .clickable { color: var(--accent-light); cursor: pointer; font-weight: 500; }
.data-table .clickable:hover { text-decoration: underline; }

@media (min-width: 700px) {
    .data-table { font-size: .88rem; }
    .data-table th { padding: 10px 12px; font-size: .78rem; }
    .data-table td { padding: 10px 12px; }
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: .7rem;
    font-weight: 500;
}
.badge-draft { background: #e5e7eb; color: #374151; }
.badge-sent { background: #dbeafe; color: #1e40af; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-accepted { background: #d1fae5; color: #065f46; }
.badge-expired { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-primary { background: #e0e7ff; color: #3730a3; }

/* ─── Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--card);
    border-radius: 12px;
    padding: 24px;
    max-width: 600px;
    width: 92%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 30px rgba(0,0,0,.15);
    position: relative;
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    border: none;
    background: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--muted);
}
.modal h2 { margin-bottom: 16px; color: var(--accent); font-size: 1.1rem; }
.modal .field { display: flex; padding: 5px 0; border-bottom: 1px solid var(--border); }
.modal .field-label { width: 120px; font-weight: 600; color: var(--muted); font-size: .8rem; flex-shrink: 0; }
.modal .field-value { font-size: .85rem; }
.modal .images { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.modal .images img { width: 70px; height: 70px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 2px solid var(--border); }
.modal .images img:hover { border-color: var(--accent); }

@media (min-width: 700px) {
    .modal { padding: 28px; }
    .modal h2 { font-size: 1.2rem; }
    .modal .field-label { width: 140px; font-size: .85rem; }
    .modal .field-value { font-size: .9rem; }
    .modal .images img { width: 80px; height: 80px; }
}

/* ─── Empty state ─── */
.empty-state {
    text-align: center;
    padding: 30px 20px;
    color: var(--muted);
    font-style: italic;
    font-size: .88rem;
}

/* ─── Footer ─── */
footer {
    text-align: center;
    padding: 14px;
    color: var(--muted);
    font-size: .75rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* ─── Buttons (shared) ─── */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: .88rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all .15s;
}
.btn-primary { background: #1f2937; color: #fff; }
.btn-primary:hover { background: #374151; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d0cdc9; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ─── Action bar (PDF actions row) ─── */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* ─── Item stock display ─── */
.item-stock {
    font-size: .72rem;
    color: var(--accent);
    margin-top: 3px;
    font-weight: 500;
}
.item-stock-empty {
    color: var(--muted);
}

/* ─── Hidden ─── */
.hidden { display: none; }
