/* ============================================================
   Water Plant Software — style.css
   Teal / blue modern theme, mobile responsive.
   Sidebar phone par band ho jata hai, menu button se khulta hai.
   ============================================================ */

:root {
    --teal: #0d9488;
    --teal-dark: #0f766e;
    --teal-light: #ccfbf1;
    --blue: #2563eb;
    --blue-dark: #1e40af;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --success: #15803d;
    --success-bg: #f0fdf4;
    --warning: #b45309;
    --warning-bg: #fffbeb;
    --info-bg: #eff6ff;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .05);
    --sidebar-w: 250px;
    --topbar-h: 58px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

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

h1, h2, h3 { margin: 0 0 12px; line-height: 1.3; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0 0 10px; }

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

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

.content { padding: 20px; flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; }

.page-footer {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 14px 10px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #0f766e 0%, #155e75 55%, #1e3a5f 100%);
    color: #fff;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .25s ease;
}

.sidebar-brand {
    padding: 18px 16px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .15);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.brand-drop { font-size: 26px; line-height: 1; }
.brand-name { font-size: 18px; font-weight: 700; }
.sidebar-brand small { color: #a7f3d0; font-size: 12px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0 16px; }

.nav-section {
    padding: 14px 18px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #99f6e4;
}

.nav-link {
    display: block;
    padding: 9px 18px;
    color: #e0f2fe;
    font-size: 14.5px;
    border-left: 3px solid transparent;
}
.nav-link:hover { background: rgba(255, 255, 255, .1); text-decoration: none; color: #fff; }
.nav-link.active { background: rgba(255, 255, 255, .16); border-left-color: #5eead4; color: #fff; font-weight: 600; }

.sidebar-foot {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, .15);
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.sidebar-foot a { color: #fda4af; }
.sidebar-foot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-overlay { display: none; }

/* ---------- Topbar ---------- */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 900;
}
.topbar-title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.topbar-title strong { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.user-chip { font-size: 14px; font-weight: 600; text-align: right; line-height: 1.2; }
.user-chip small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }

.menu-btn {
    display: none;
    background: var(--teal);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 38px; height: 38px;
    font-size: 19px;
    cursor: pointer;
    flex-shrink: 0;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 18px;
}
.card h2, .card h3 { margin-bottom: 10px; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--teal);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}
.stat-card.blue { border-left-color: var(--blue); }
.stat-card.amber { border-left-color: #d97706; }
.stat-card.red { border-left-color: var(--danger); }
.stat-card .label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.stat-card .value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-card .sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
td.wrap, th.wrap { white-space: normal; }
thead th { background: #f8fafc; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr:hover { background: #f8fafc; }
tfoot td { font-weight: 700; background: #f8fafc; }
td.num, th.num { text-align: right; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-muted { color: var(--muted); }

/* ---------- Forms ---------- */
.form-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 14px; }
.form-group { flex: 1 1 200px; display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-weight: 600; font-size: 13.5px; }
.form-group small { color: var(--muted); font-size: 12px; }

input[type="text"], input[type="number"], input[type="date"], input[type="email"],
input[type="password"], input[type="tel"], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, .18);
}
textarea { resize: vertical; min-height: 70px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.search-input { max-width: 260px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    line-height: 1.3;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: .92; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; border-color: #cbd5e1; color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { display: block; width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Alerts / badges ---------- */
.alert { padding: 12px 15px; border-radius: 8px; margin-bottom: 16px; font-size: 14.5px; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-info { background: var(--info-bg); color: var(--blue-dark); border: 1px solid #bfdbfe; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #fde68a; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}
.badge-green { background: #dcfce7; color: var(--success); }
.badge-red { background: #fee2e2; color: var(--danger); }
.badge-amber { background: #fef3c7; color: var(--warning); }
.badge-blue { background: #dbeafe; color: var(--blue-dark); }
.badge-grey { background: #e2e8f0; color: var(--muted); }

/* ---------- Login ---------- */
.login-body {
    background: linear-gradient(135deg, #0f766e, #155e75 60%, #1e3a5f);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.login-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
    padding: 30px 26px;
    width: 100%;
    max-width: 400px;
}
.login-logo {
    width: 62px; height: 62px;
    border-radius: 50%;
    background: var(--teal-light);
    color: var(--teal-dark);
    font-size: 30px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 12px;
    font-weight: 700;
}
.login-card h1 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* ---------- Misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; }
.list-plain li:last-child { border-bottom: none; }

/* ============================================================
   PRINT — A4 (invoice / report)
   ============================================================ */
@media print {
    body { background: #fff; font-size: 13px; }
    .sidebar, .topbar, .page-footer, .no-print { display: none !important; }
    .main-wrap { margin-left: 0; }
    .content { padding: 0; max-width: none; }
    .card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
    a { color: #000; }
    @page { size: A4; margin: 12mm; }
}

/* ============================================================
   PRINT — Thermal receipt (80mm)
   .thermal class wali receipt chhoti printer par chhapti hai.
   ============================================================ */
@media print {
    .thermal {
        width: 72mm;
        margin: 0 auto;
        font-size: 12px;
        font-family: "Courier New", monospace;
    }
    .thermal h1, .thermal h2, .thermal h3 { font-size: 14px; text-align: center; }
    .thermal table { font-size: 12px; }
    .thermal th, .thermal td { padding: 2px 4px; }
    .thermal .center { text-align: center; }
    .thermal hr { border: none; border-top: 1px dashed #000; margin: 6px 0; }
}

/* ============================================================
   MOBILE — sidebar off-canvas, cards full width
   ============================================================ */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .5);
        z-index: 950;
    }
    .main-wrap { margin-left: 0; }
    .menu-btn { display: block; }
    .content { padding: 14px 12px; }
    .user-chip small { display: none; }
    .card-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .stat-card .value { font-size: 21px; }
    h1 { font-size: 20px; }
    .toolbar .btn { flex: 1 1 auto; }
    .search-input { max-width: none; flex: 1 1 100%; }
}
