/* Biofleet Logistics — Web app styles
 * Color palette matches the Tkinter desktop app for visual continuity.
 */
:root {
    --primary:       #0891B2;
    --primary-dark:  #0E7490;
    --primary-light: #E0F7FA;
    --bg:            #F1F5F9;
    --surface:       #FFFFFF;
    --sidebar:       #0F172A;
    --sidebar-hover: #1E293B;
    --sidebar-active:#0E7490;
    --sidebar-text:  #94A3B8;
    --text:          #0F172A;
    --text-muted:    #64748B;
    --border:        #E2E8F0;
    --success:       #16A34A;
    --warning:       #F59E0B;
    --danger:        #DC2626;
    --stage-Researched: #94A3B8;
    --stage-Contacted:  #3B82F6;
    --stage-Meeting:    #8B5CF6;
    --stage-Proposal:   #F59E0B;
    --stage-Won:        #16A34A;
    --stage-Lost:       #94A3B8;
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                  'Helvetica Neue', Arial, sans-serif;
    background: var(--bg); color: var(--text);
    font-size: 14px; line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ====== LAYOUT ====== */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: 220px; height: 100vh;
    background: var(--sidebar);
    color: white;
    display: flex; flex-direction: column;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.2s ease;
}
.sidebar .brand {
    display: block;
    padding: 20px 16px 16px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar .brand img {
    max-width: 180px;
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}
.sidebar nav {
    flex: 1;
    padding: 8px 0;
}
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}
.sidebar nav a:hover {
    background: var(--sidebar-hover);
    color: white;
}
.sidebar nav a.active {
    background: var(--sidebar-active);
    color: white;
    border-left-color: var(--primary);
}
.sidebar nav .icon {
    font-size: 16px;
    width: 20px; text-align: center;
    flex-shrink: 0;
}
.sidebar .phone-only { display: none; }
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}
.sidebar-footer .logout {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    text-decoration: none;
}
.sidebar-footer .logout:hover { color: white; }

.content {
    margin-left: 220px;
    padding: 24px;
    min-height: 100vh;
}

.mobile-menu-toggle {
    display: none;
    position: fixed; top: 12px; left: 12px;
    z-index: 101;
    background: var(--sidebar);
    color: white;
    border: none;
    width: 40px; height: 40px;
    font-size: 20px;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ====== MOBILE ====== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    body.nav-open .sidebar {
        transform: translateX(0);
    }
    .sidebar .phone-only { display: flex; }
    .content {
        margin-left: 0;
        padding: 60px 12px 24px;
    }
    .mobile-menu-toggle {
        display: block;
    }
}

/* ====== TYPE ====== */
h1 { font-size: 22px; font-weight: 700; margin: 0 0 6px; color: var(--text); }
h2 { font-size: 17px; font-weight: 700; margin: 0 0 6px; }
h3 { font-size: 14px; font-weight: 700; margin: 0 0 4px; }
.muted { color: var(--text-muted); font-size: 13px; }

/* ====== CARDS / SECTIONS ====== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.card-header h2 { margin: 0; }

/* ====== STAT CARDS (dashboard) ====== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}
.stat-card .label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.stat-card .value {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-top: 4px;
}
.stat-card.success .value { color: var(--success); }
.stat-card.warning .value { color: var(--warning); }
.stat-card.danger  .value { color: var(--danger); }
.stat-card.muted   .value { color: var(--text-muted); }

/* ====== BUTTONS ====== */
.btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.1s;
}
.btn:hover { background: var(--bg); }
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}
.btn-danger:hover { opacity: 0.9; }
.btn-success {
    background: var(--success); border-color: var(--success); color: white;
}
.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ====== FORMS ====== */
.form-row {
    display: flex; gap: 12px; margin-bottom: 12px;
    flex-wrap: wrap;
}
.form-row > .form-field { flex: 1; min-width: 200px; }
.form-field label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="time"],
.form-field input[type="file"],
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: white;
    color: var(--text);
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
    border-color: var(--primary);
}
.form-field textarea { min-height: 80px; resize: vertical; }
.form-field input[type="checkbox"],
.form-field input[type="radio"] {
    margin-right: 6px;
}
.form-field.checkbox-inline {
    flex: none;
    display: flex; align-items: center;
}
.form-field.checkbox-inline label {
    display: inline; margin: 0;
    color: var(--text); font-size: 13px;
    font-weight: normal;
}

.form-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
    margin-top: 16px;
}

/* ====== TABLES ====== */
.tbl-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    overflow-x: auto;
}
table.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.tbl th, table.tbl td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.tbl th {
    background: var(--bg);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}
table.tbl tbody tr:hover {
    background: var(--bg);
}
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl td.right, table.tbl th.right { text-align: right; }
table.tbl td.num { font-variant-numeric: tabular-nums; }

.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-muted);
}

/* ====== STAGE BADGES ====== */
.stage-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.stage-badge.researched { background: var(--stage-Researched); }
.stage-badge.contacted  { background: var(--stage-Contacted); }
.stage-badge.meeting    { background: var(--stage-Meeting); }
.stage-badge.proposal   { background: var(--stage-Proposal); }
.stage-badge.won        { background: var(--stage-Won); }
.stage-badge.lost       { background: var(--stage-Lost); }

/* ====== PIPELINE (Kanban) ====== */
.kanban {
    display: grid;
    grid-template-columns: repeat(6, minmax(180px, 1fr));
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
}
.kanban-col {
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
    min-height: 400px;
    display: flex; flex-direction: column;
}
.kanban-col-header {
    padding: 10px;
    border-radius: 8px 8px 0 0;
    color: white;
    font-weight: 600;
    font-size: 13px;
    display: flex; justify-content: space-between;
    align-items: center;
}
.kanban-col-header[data-stage="Researched"] { background: var(--stage-Researched); }
.kanban-col-header[data-stage="Contacted"]  { background: var(--stage-Contacted); }
.kanban-col-header[data-stage="Meeting"]    { background: var(--stage-Meeting); }
.kanban-col-header[data-stage="Proposal"]   { background: var(--stage-Proposal); }
.kanban-col-header[data-stage="Won"]        { background: var(--stage-Won); }
.kanban-col-header[data-stage="Lost"]       { background: var(--stage-Lost); }
.kanban-col-body {
    padding: 8px;
    overflow-y: auto;
    flex: 1;
    max-height: 70vh;
}
.kanban-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 6px;
    cursor: grab;
    transition: box-shadow 0.1s;
    font-size: 13px;
}
.kanban-card:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.kanban-card .name { font-weight: 600; }
.kanban-card .meta {
    font-size: 11px; color: var(--text-muted);
    margin-top: 2px;
}
.kanban-card.dragging { opacity: 0.5; }

@media (max-width: 768px) {
    .kanban { grid-template-columns: 1fr; }
    .kanban-col-body { max-height: none; }
}

/* ====== CALENDAR ====== */
.calendar-grid {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    overflow-x: auto;
}
.calendar-nav {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 12px;
}
.calendar-nav .month-name {
    font-size: 18px; font-weight: 600;
    min-width: 180px;
}
.cal-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 2px;
    min-width: 720px;
}
.cal-table th {
    background: var(--bg);
    color: var(--text-muted);
    font-size: 11px;
    padding: 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.cal-day {
    border: 1px solid var(--border);
    height: 90px;
    vertical-align: top;
    padding: 4px;
    background: var(--surface);
    font-size: 12px;
}
.cal-day.other-month {
    background: var(--bg);
    color: var(--text-muted);
}
.cal-day.today {
    border-color: var(--primary-dark);
    background: var(--primary-light);
}
.cal-day .daynum {
    font-weight: 600;
    margin-bottom: 2px;
}
.cal-event {
    display: block;
    font-size: 11px;
    padding: 1px 4px;
    border-radius: 3px;
    margin-bottom: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: white;
    text-decoration: none;
}
.cal-event.meeting   { background: var(--stage-Meeting); }
.cal-event.followup  { background: var(--primary); }
.cal-event.agreement { background: var(--success); }
.cal-event.invoice   { background: var(--warning); }

.cal-legend {
    display: flex; gap: 12px; flex-wrap: wrap;
    margin-bottom: 12px; font-size: 12px;
}
.cal-legend .dot {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 50%; margin-right: 4px;
}

/* ====== FLASH ====== */
.flash {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 12px;
    border: 1px solid;
}
.flash-success { background: #DCFCE7; border-color: var(--success); color: #166534; }
.flash-error   { background: #FEE2E2; border-color: var(--danger);  color: #991B1B; }
.flash-info    { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }

/* ====== STATUS PILLS ====== */
.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.pill.draft  { background: var(--bg); color: var(--text-muted); }
.pill.sent   { background: #DBEAFE; color: #1E40AF; }
.pill.paid   { background: #DCFCE7; color: #166534; }
.pill.overdue { background: #FEE2E2; color: #991B1B; }
.pill.active { background: #DCFCE7; color: #166534; }
.pill.inactive { background: var(--bg); color: var(--text-muted); }
.pill.high   { background: #FEE2E2; color: #991B1B; }
.pill.medium { background: #FEF3C7; color: #92400E; }
.pill.low    { background: var(--bg); color: var(--text-muted); }

/* ====== HEADERS ====== */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 8px;
    margin-bottom: 16px;
}
.page-header h1 { margin: 0; }
.page-header .actions {
    display: flex; gap: 8px; flex-wrap: wrap;
}

/* ====== LOGIN ====== */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--sidebar);
    padding: 20px;
}
.login-card {
    background: var(--surface);
    padding: 32px;
    border-radius: 12px;
    max-width: 420px;
    width: 100%;
    text-align: center;
}
.login-card img { max-width: 200px; margin-bottom: 16px; }
.login-card p { color: var(--text-muted); font-size: 13px; }

/* ====== UTILITY ====== */
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-1 { gap: 8px; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.no-wrap { white-space: nowrap; }
.w-100 { width: 100%; }

/* ====== TABS ====== */
.tabs {
    display: flex; gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
    overflow-x: auto;
}
.tabs a, .tabs button {
    padding: 8px 14px;
    background: none;
    border: none;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    font-weight: 500;
}
.tabs a.active, .tabs button.active {
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ====== EXPENSE BREAKDOWN BARS ====== */
.bar-row {
    margin-bottom: 8px;
}
.bar-row .label {
    font-size: 12px;
    display: flex; justify-content: space-between;
}
.bar {
    height: 12px;
    background: var(--bg);
    border-radius: 2px;
    margin-top: 2px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    background: var(--primary);
}

/* Package selector card */
.package-card {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.package-card:hover { border-color: var(--primary); }
.package-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}
.package-card .price {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-dark);
}

/* Receipt thumbnail */
.thumb { max-width: 80px; max-height: 80px; border-radius: 4px; }
