:root {
    --primary: #1f7a8c;
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --danger: #b91c1c;
    --success: #047857;
    --radius: 14px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", "Noto Sans", "Roboto", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #eef2f7;
    color: var(--text);
    padding: 20px;
    border-right: 1px solid #dbe3ee;
}
.sidebar-logo {
    width: 100%;
    max-width: 180px;
    display: block;
    margin: 0 auto 12px;
    border-radius: 10px;
    background: #fff;
    padding: 6px;
}
.sidebar h2 { margin-top: 0; font-size: 20px; color: #0f172a; }
.nav-link {
    display: block;
    color: #111827;
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 8px;
    font-weight: 700;
    background: #e5e7eb;
    border: 1px solid transparent;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.nav-link.active, .nav-link:hover {
    background: var(--primary);
    color: #fff;
}
.nav-link.danger {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}
.nav-link.danger:hover {
    background: #fca5a5;
    color: #7f1d1d;
}

.content { padding: 24px; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 14px;
    flex-wrap: wrap;
}
.company-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.topbar-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
    border: none;
    background: #e5e7eb;
    color: #111827;
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    display: inline-block;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: #0f766e; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-big { padding: 14px 20px; font-size: 16px; }

.panel {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    margin-bottom: 20px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.card h3 { margin: 0 0 8px; font-size: 15px; }
.card p { margin: 0; font-size: 22px; font-weight: 700; }
.card-quarter p { margin-bottom: 6px; }
.card-meta {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.quarter-filter {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quarter-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    padding: 4px 10px;
    cursor: pointer;
}

.quarter-option input {
    width: auto;
    margin: 0;
    padding: 0;
}

.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.split-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(220px,1fr));
    gap: 16px;
}

.form-grid {
    display: grid;
    gap: 12px;
}
.form-grid label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font-size: 15px;
}
textarea { min-height: 90px; }

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
th, td {
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
}
.actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.status-chip {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}

.status-default {
    background: #e5e7eb;
    color: #111827;
}

.status-unpaid {
    background: #fee2e2;
    color: #991b1b;
}

.status-partial {
    background: #ffedd5;
    color: #9a3412;
}

.status-paid {
    background: #dcfce7;
    color: #166534;
}

.alert {
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 10px;
    font-weight: 700;
}
.alert.success { background: #dcfce7; color: #14532d; }
.alert.error { background: #fee2e2; color: #7f1d1d; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
}
.auth-card {
    width: min(480px, 92%);
    background: #fff;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,.08);
}

.items-block { overflow-x: auto; }
.items-block table input,
.items-block table select,
.items-block table textarea {
    min-width: 110px;
}
.items-block table .item-description {
    min-width: 260px;
    min-height: 70px;
    resize: both;
    overflow: auto;
}
.settings-pricing-table input,
.settings-pricing-table select {
    min-width: 90px;
}
.small-form { max-width: 520px; }
.notice { background: #fff7ed; padding: 10px; border-radius: 10px; }
.live-search { margin-bottom: 8px; }
.mini-form { display: grid; gap: 6px; margin-top: 8px; max-width: 220px; }
.logo-preview-wrap {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px;
}
.logo-preview-wrap p {
    margin: 0 0 8px;
    font-weight: 700;
}
.logo-preview {
    width: 220px;
    max-width: 100%;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
    padding: 6px;
}

@media (max-width: 1024px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { display: flex; gap: 8px; flex-wrap: wrap; }
    .sidebar h2 { width: 100%; }
    .split { grid-template-columns: 1fr; }
}
