/* =====================================================================
   GenF Billing - Main stylesheet
   Minimalistic, flat design. Ocean Blue + Orange on white.
   ===================================================================== */

:root {
    --blue:        #0077B6;
    --blue-dark:   #005f92;
    --blue-soft:   #e6f2f9;
    --orange:      #FF7A00;
    --orange-dark: #e46e00;
    --white:       #FFFFFF;
    --bg:          #f6f8fa;
    --text:        #1f2a37;
    --muted:       #6b7280;
    --border:      #e5e7eb;
    --green:       #16a34a;
    --red:         #dc2626;
    --radius:      10px;
    --shadow:      0 1px 2px rgba(16,24,40,.06);
    --sidebar-w:   232px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; }

/* ---------------------------------------------------------------- Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 30;
}

.brand {
    display: flex; align-items: baseline; gap: 4px;
    padding: 22px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 22px; font-weight: 700;
}
.brand-mark { color: var(--blue); }
.brand-text { color: var(--orange); }

.nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 8px;
    color: var(--text); text-decoration: none; font-weight: 500;
    transition: background .12s ease, color .12s ease;
}
.nav-link:hover { background: var(--blue-soft); text-decoration: none; }
.nav-link.active { background: var(--blue); color: #fff; }
.nav-icon { width: 22px; text-align: center; font-size: 16px; }
.sidebar-footer { padding: 10px; border-top: 1px solid var(--border); }

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex; flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex; align-items: center; gap: 16px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 19px; flex: 1; }
.menu-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; }

.topbar-right { display: flex; align-items: center; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--blue); color: #fff;
    display: grid; place-items: center; font-weight: 600;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 14px; }
.user-role { font-size: 12px; color: var(--muted); }

.content { padding: 24px; flex: 1; }
.app-footer {
    display: flex; justify-content: space-between;
    padding: 16px 24px; color: var(--muted); font-size: 13px;
    border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------- Cards */
.cards-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 16px; margin-bottom: 24px;
}
.cards-grid.cards-3 { grid-template-columns: repeat(3, 1fr); }

.stat-card {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px;
    display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
}
.stat-icon {
    width: 46px; height: 46px; border-radius: 10px;
    display: grid; place-items: center; font-size: 22px;
    background: var(--blue-soft);
}
.stat-blue   .stat-icon { background: #e6f2f9; }
.stat-orange .stat-icon { background: #fff0e0; }
.stat-red    .stat-icon { background: #fde8e8; }
.stat-green  .stat-icon { background: #e7f6ee; }
.stat-body { display: flex; flex-direction: column; }
.stat-value { font-size: 21px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- Panels */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

.panel {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow);
    overflow: hidden;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 16px; }
.panel-body { padding: 18px; }
.form-panel { max-width: 820px; }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
    padding: 11px 12px; text-align: left;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
.table tbody tr:hover { background: #fafbfc; }
.table .right { text-align: right; }
.table .empty { text-align: center; color: var(--muted); padding: 26px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.inline-form { display: inline; }

/* ---------------------------------------------------------------- Badges */
.badge {
    display: inline-block; padding: 2px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
}
.badge-gray   { background: #eef1f4; color: #4b5563; }
.badge-blue   { background: var(--blue-soft); color: var(--blue-dark); }
.badge-green  { background: #e7f6ee; color: var(--green); }
.badge-red    { background: #fde8e8; color: var(--red); }
.badge-orange { background: #fff0e0; color: var(--orange-dark); }

/* ---------------------------------------------------------------- Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
    font-size: 14px; font-weight: 600; cursor: pointer;
    text-decoration: none; transition: background .12s ease, border-color .12s ease;
    background: #eef1f4; color: var(--text);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-accent  { background: var(--orange); color: #fff; }
.btn-accent:hover { background: var(--orange-dark); }
.btn-ghost   { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: #f3f5f7; }
.btn-danger  { background: #fde8e8; color: var(--red); }
.btn-danger:hover { background: #fbd5d5; }
.btn-block   { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 9px; font-size: 12px; }

/* ---------------------------------------------------------------- Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.req { color: var(--red); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], select, textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,119,182,.12);
}
textarea { resize: vertical; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-full { grid-column: 1 / -1; }
.checkbox-field { flex-direction: row; align-items: center; gap: 8px; grid-column: 1 / -1; }
.checkbox-field input { width: auto; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-bar input, .filter-bar select { width: auto; min-width: 130px; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline .field-label { margin: 0; }
.search-form { display: flex; gap: 8px; }
.search-form input { width: auto; }

/* ---------------------------------------------------------------- Detail */
.detail-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.detail-list { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; }
.detail-list dt { color: var(--muted); font-weight: 600; }
.detail-list dd { margin: 0; }

/* ---------------------------------------------------------------- Summary */
.summary-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px dashed var(--border);
}
.summary-row.grand { font-size: 18px; font-weight: 700; color: var(--blue); border-bottom: none; border-top: 2px solid var(--border); margin-top: 4px; padding-top: 12px; }
.summary-row.balance { font-weight: 700; color: var(--orange-dark); }
.discount-input { display: flex; gap: 6px; }
.discount-input select { width: 70px; }
.discount-input input { width: 110px; }
.summary-inline { color: var(--muted); margin: 0 0 12px; }

/* ---------------------------------------------------------------- Items table */
.items-table input, .items-table select { padding: 7px 8px; font-size: 13px; }
.items-table .line-total { font-weight: 600; }

/* ---------------------------------------------------------------- Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #e7f6ee; color: #14683f; border: 1px solid #b7e4c7; }
.alert-error   { background: #fde8e8; color: #9b1c1c; border: 1px solid #f5c2c2; }
.alert-info    { background: var(--blue-soft); color: var(--blue-dark); border: 1px solid #bfe0f0; }

/* ---------------------------------------------------------------- Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab { padding: 10px 16px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.tab:hover { text-decoration: none; color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ---------------------------------------------------------------- Misc */
.empty { color: var(--muted); }
.muted { color: var(--muted); }
.hidden { display: none; }
.pay-form { padding: 16px; background: #fafbfc; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 16px; }

/* ---------------------------------------------------------------- Auth */
.auth-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, #eaf4fb, #fff); }
.auth-card {
    width: 360px; max-width: 92vw; background: #fff;
    border: 1px solid var(--border); border-radius: 14px; padding: 32px; box-shadow: 0 10px 40px rgba(16,24,40,.08);
}
.auth-brand { font-size: 28px; font-weight: 700; text-align: center; }
.auth-brand .brand-mark { color: var(--blue); }
.auth-brand .brand-text { color: var(--orange); }
.auth-sub { text-align: center; color: var(--muted); margin: 6px 0 22px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-hint { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 18px; }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 960px) {
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .cards-grid.cards-3 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-toggle { display: block; }
    .form-grid { grid-template-columns: 1fr; }
    .cards-grid { grid-template-columns: 1fr; }
}
