/* =====================================================================
   SHREYA INFRATECH - STORE MANAGEMENT SYSTEM
   Brand colours sampled directly from the company logo.
   No web fonts are loaded: field staff open this on patchy mobile data,
   so the system font stack is a deliberate choice.
   ===================================================================== */

:root {
  --brand:        #F97C0E;   /* logo flame orange */
  --brand-dark:   #DC6605;
  --brand-light:  #FFF1E3;
  --charcoal:     #313131;   /* logo gear charcoal */
  --charcoal-2:   #414141;
  --ink:          #1F2225;
  --muted:        #6B7280;
  --line:         #E4E7EB;
  --bg:           #F4F6F8;
  --card:         #FFFFFF;

  --ok:           #157347;
  --warn:         #B26A00;
  --bad:          #B02A37;

  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 2px rgba(16,24,40,.05), 0 4px 12px rgba(16,24,40,.06);
  --shadow-lg:    0 8px 28px rgba(16,24,40,.12);

  --sidebar-w:    248px;
  --topbar-h:     60px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
  -webkit-text-size-adjust: 100%;
}

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

/* ---------------------------------------------------------------
   APP SHELL
   --------------------------------------------------------------- */
.app-sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--charcoal);
  color: #D7DBE0;
  display: flex; flex-direction: column;
  z-index: 1040;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.app-sidebar .brand {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.09);
  display: flex; align-items: center; gap: 10px;
}
.app-sidebar .brand img { height: 38px; width: auto; background: #fff; border-radius: 6px; padding: 3px; }
.app-sidebar .brand .bt { font-weight: 700; font-size: 14px; color: #fff; line-height: 1.15; letter-spacing: .2px; }
.app-sidebar .brand .bs { font-size: 10px; color: var(--brand); letter-spacing: .6px; }

.app-sidebar .nav-section {
  padding: 14px 16px 6px;
  font-size: 11px; letter-spacing: .8px;
  color: #8A9199; font-weight: 600;
}
.app-sidebar .nav-link {
  color: #D7DBE0;
  padding: 9px 16px;
  display: flex; align-items: center; gap: 11px;
  border-left: 3px solid transparent;
  font-size: 14.5px;
  text-decoration: none;
}
.app-sidebar .nav-link i { width: 18px; text-align: center; font-size: 15px; opacity: .85; }
.app-sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.app-sidebar .nav-link.active {
  background: rgba(249,124,14,.14);
  border-left-color: var(--brand);
  color: #fff; font-weight: 600;
}
.app-sidebar .nav-link.active i { opacity: 1; color: var(--brand); }
.app-sidebar .sb-foot { margin-top: auto; padding: 14px 16px; font-size: 11.5px; color: #7C848D; border-top: 1px solid rgba(255,255,255,.08); }

.app-main { margin-left: var(--sidebar-w); min-height: 100vh; }

.app-topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  position: sticky; top: 0; z-index: 1030;
}
.app-topbar .gsearch { flex: 1; max-width: 520px; position: relative; }
.app-topbar .gsearch input {
  width: 100%; height: 40px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0 16px 0 40px; font-size: 14.5px; background: var(--bg);
}
.app-topbar .gsearch input:focus { outline: 2px solid var(--brand); outline-offset: -1px; background: #fff; }
.app-topbar .gsearch .gs-ico { position: absolute; left: 15px; top: 11px; color: var(--muted); }

.page { padding: 20px; max-width: 1500px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 21px; font-weight: 700; margin: 0; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin: 2px 0 0; }
.page-head .spacer { margin-left: auto; }

/* ---------------------------------------------------------------
   CARDS + KPI TILES
   --------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  background: #fff; border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: 15px;
  padding: 13px 16px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow); height: 100%;
  display: block; color: inherit; text-decoration: none;
}
a.kpi:hover { border-color: var(--brand); text-decoration: none; box-shadow: var(--shadow-lg); }
.kpi .k-lab { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi .k-val { font-size: 27px; font-weight: 700; line-height: 1.15; margin-top: 3px; letter-spacing: -.5px; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .k-ico {
  float: right; width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; font-size: 17px;
  background: var(--brand-light); color: var(--brand-dark);
}
.kpi.k-danger  .k-ico { background: #FDECEE; color: var(--bad); }
.kpi.k-danger  .k-val { color: var(--bad); }
.kpi.k-warn    .k-ico { background: #FFF6E5; color: var(--warn); }
.kpi.k-warn    .k-val { color: var(--warn); }
.kpi.k-ok      .k-ico { background: #E8F5EE; color: var(--ok); }

/* ---------------------------------------------------------------
   TABLES
   --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { margin: 0; font-size: 14px; }
.table > thead > tr > th {
  background: #FAFBFC;
  border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 600; color: #4B5563;
  letter-spacing: .2px; white-space: nowrap;
  padding: 10px 12px;
}
.table > tbody > tr > td { padding: 10px 12px; vertical-align: middle; border-color: #EEF1F4; }
.table > tbody > tr:hover { background: #FCFCFD; }
.table thead th a { color: #4B5563; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

.badge-soft { font-weight: 600; font-size: 11.5px; padding: 4px 9px; border-radius: 999px; }
.bs-success { background: #E8F5EE; color: var(--ok); }
.bs-warning { background: #FFF6E5; color: var(--warn); }
.bs-danger  { background: #FDECEE; color: var(--bad); }
.bs-info    { background: #E7F1FD; color: #0A58CA; }
.bs-primary { background: var(--brand-light); color: var(--brand-dark); }
.bs-secondary { background: #EEF0F3; color: #4B5563; }
.bs-dark    { background: #E2E4E7; color: #22262A; }

.sku-chip {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: #F1F3F5; border-radius: 5px; padding: 2px 6px;
}

/* ---------------------------------------------------------------
   BUTTONS + FORMS
   --------------------------------------------------------------- */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: 14.5px; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-charcoal { background: var(--charcoal); border-color: var(--charcoal); color: #fff; }
.btn-charcoal:hover { background: #000; border-color: #000; color: #fff; }
.btn-lg { padding: 11px 20px; font-size: 16px; }

.form-label { font-weight: 600; font-size: 13px; color: #374151; margin-bottom: 4px; }
.form-control, .form-select {
  border-color: var(--line); border-radius: var(--radius-sm);
  font-size: 15px; padding: 9px 12px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(249,124,14,.15);
}
.form-control[readonly] { background: #F7F8F9; }
.req::after { content: " *"; color: var(--bad); }
.help { font-size: 12.5px; color: var(--muted); }

.filter-bar {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 16px; box-shadow: var(--shadow);
}

/* Line-item builder used by Receive / Issue / Return / Install */
.items-table td { padding: 6px 8px; }
.items-table .form-control, .items-table .form-select { font-size: 14.5px; padding: 7px 10px; }
.avail-hint { font-size: 12px; font-weight: 600; }
.avail-ok  { color: var(--ok); }
.avail-bad { color: var(--bad); }

/* ---------------------------------------------------------------
   PLUMBER MOBILE HOME
   --------------------------------------------------------------- */
.pl-hero {
  background: linear-gradient(135deg, var(--charcoal) 0%, #1E1E1E 100%);
  color: #fff; border-radius: 0 0 20px 20px;
  padding: 18px 18px 26px;
}
.pl-hero .hi { font-size: 21px; font-weight: 700; }
.pl-hero .dt { color: #A8AEB5; font-size: 13px; }
.pl-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.pl-stat { background: rgba(255,255,255,.09); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.pl-stat .v { font-size: 22px; font-weight: 700; line-height: 1.1; }
.pl-stat .l { font-size: 11px; color: #B9BEC4; margin-top: 2px; }

.big-action {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 11px; box-shadow: var(--shadow);
  color: var(--ink); font-weight: 600; font-size: 16px; text-decoration: none;
  min-height: 62px;
}
.big-action:hover, .big-action:active { border-color: var(--brand); color: var(--ink); text-decoration: none; }
.big-action .ico {
  width: 44px; height: 44px; border-radius: 11px; flex: 0 0 44px;
  display: grid; place-items: center; font-size: 20px;
  background: var(--brand-light); color: var(--brand-dark);
}
.big-action.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.big-action.primary .ico { background: rgba(255,255,255,.2); color: #fff; }
.big-action .chev { margin-left: auto; color: #C3C8CE; }
.big-action .sub { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); }
.big-action.primary .sub { color: rgba(255,255,255,.85); }

/* Mobile bottom navigation */
.bottom-nav { display: none; }

/* Step wizard */
.steps { display: flex; gap: 4px; margin-bottom: 14px; }
.steps .st { flex: 1; height: 5px; border-radius: 3px; background: #DFE3E8; }
.steps .st.done { background: var(--brand); }
.step-title { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }

/* Photo thumbs */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 10px; }
.photo-grid a { display: block; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.photo-grid img { width: 100%; height: 130px; object-fit: cover; display: block; }
.photo-grid .cap { font-size: 11.5px; padding: 5px 7px; color: var(--muted); font-weight: 600; }

/* Detail definition lists */
.dl-clean { margin: 0; }
.dl-clean dt { font-size: 12px; color: var(--muted); font-weight: 500; }
.dl-clean dd { font-size: 15px; font-weight: 600; margin: 0 0 12px; word-break: break-word; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty i { font-size: 34px; color: #C9CED4; display: block; margin-bottom: 10px; }
.empty h6 { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------------- */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  .app-sidebar.open { transform: none; }
  .app-main { margin-left: 0; }
  .page { padding: 14px; padding-bottom: 84px; }
  .sb-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1035;
  }
  .kpi .k-val { font-size: 23px; }

  .bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff; border-top: 1px solid var(--line);
    z-index: 1050;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    flex: 1; text-align: center; padding: 8px 2px 7px;
    color: var(--muted); font-size: 10.5px; font-weight: 600;
    text-decoration: none; min-height: 54px;
  }
  .bottom-nav a i { display: block; font-size: 19px; margin-bottom: 2px; }
  .bottom-nav a.active { color: var(--brand-dark); }
  .table { font-size: 13.5px; }
  .page-head h1 { font-size: 18px; }
}

@media (max-width: 575.98px) {
  .page-head .spacer { margin-left: 0; width: 100%; }
  .page-head .spacer .btn { width: 100%; }
  .pl-stats { gap: 8px; }
}

/* Bigger touch targets on real touch devices */
@media (pointer: coarse) {
  .btn, .form-control, .form-select { min-height: 46px; }
  .table td .btn-sm { min-height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------
   PRINT  (A4 documents: issue slip, GRN, reports)
   --------------------------------------------------------------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .app-sidebar, .app-topbar, .bottom-nav, .no-print,
  .filter-bar, .sb-backdrop, .pagination { display: none !important; }
  .app-main { margin-left: 0 !important; }
  .page { padding: 0 !important; max-width: none; }
  .card { border: none !important; box-shadow: none !important; }
  .card-header { border-bottom: 1px solid #000; }
  a { color: #000 !important; text-decoration: none !important; }
  .table > thead > tr > th { background: #EEE !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table, .table th, .table td { border: 1px solid #999 !important; }
  .print-only { display: block !important; }
  .avoid-break { break-inside: avoid; page-break-inside: avoid; }
}
.print-only { display: none; }

/* ---------------------------------------------------------------
   PRINT DOCUMENT LAYOUT (used by /print/*.php)
   --------------------------------------------------------------- */
.doc { max-width: 210mm; margin: 0 auto; background: #fff; padding: 22px; }
.doc-head { display: flex; align-items: flex-start; gap: 14px; border-bottom: 2.5px solid var(--brand); padding-bottom: 12px; }
.doc-head img { height: 62px; }
.doc-head .co { font-size: 21px; font-weight: 800; color: var(--charcoal); letter-spacing: -.3px; }
.doc-head .tg { font-size: 11px; color: var(--brand-dark); font-weight: 700; letter-spacing: 1.2px; }
.doc-head .addr { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.doc-title { text-align: center; font-size: 15px; font-weight: 800; letter-spacing: 2px; margin: 14px 0; padding: 7px; background: #F3F4F6; border-radius: 4px; }
.doc-meta { width: 100%; font-size: 13px; margin-bottom: 12px; }
.doc-meta td { padding: 3px 6px; vertical-align: top; }
.doc-meta .lab { color: var(--muted); width: 92px; font-size: 12px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.doc-table th, .doc-table td { border: 1px solid #B9BEC4; padding: 6px 8px; }
.doc-table th { background: #F3F4F6; font-size: 11.5px; text-align: left; }
.sign-row { display: flex; gap: 22px; margin-top: 42px; }
.sign-box { flex: 1; text-align: center; font-size: 12px; }
.sign-box .ln { border-top: 1px solid #666; margin-bottom: 5px; height: 42px; }
.doc-foot { margin-top: 20px; font-size: 10.5px; color: var(--muted); border-top: 1px dashed #C7CCD1; padding-top: 8px; }
