/* Harsha Agencies - Internal App
   Placeholder brand palette (deep green + amber) - swap for the real
   Harsha Agencies / Amazon-premium-distributor brand colors once provided. */

:root {
  --brand: #0b5d3b;
  --brand-dark: #073d27;
  --brand-light: #e6f2ec;
  --accent: #c47a1c;
  --ink: #1c1f1e;
  --muted: #6b736f;
  --line: #e2e6e4;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --danger: #b3261e;
  --danger-bg: #fbe9e7;
  --success: #1e7d4c;
  --success-bg: #e6f4ec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.06), 0 4px 12px rgba(20, 30, 25, 0.06);
}

* { box-sizing: border-box; }

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

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

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------------- Topbar ---------------- */
.topbar { background: var(--brand); color: #fff; }
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 24px; height: 58px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
  width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.brand-name { font-weight: 600; font-size: 16px; }
.main-nav { display: flex; gap: 4px; flex: 1; }
.main-nav a {
  color: #d9ece2; padding: 8px 12px; border-radius: 6px; font-size: 14px; font-weight: 500;
}
.main-nav a:hover { text-decoration: none; background: rgba(255,255,255,0.08); color: #fff; }
.main-nav a.active { background: rgba(255,255,255,0.16); color: #fff; }
.user-menu { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #d9ece2; }
.role-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.15); color: #fff;
}
.role-badge.role-manager { background: var(--accent); }
.link-btn {
  background: none; border: none; color: #d9ece2; cursor: pointer; font-size: 13px; padding: 0; font-family: inherit;
}
.link-btn:hover { color: #fff; text-decoration: underline; }
.inline-form { display: inline; }

/* ---------------- Layout ---------------- */
.app-main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; width: 100%; flex: 1; }
.app-footer { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

.blank-body {
  background: linear-gradient(160deg, var(--brand-dark), var(--brand) 60%);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}

/* ---------------- Page header ---------------- */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { margin: 0; font-size: 22px; }
.page-header p.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Cards / surfaces ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card h2, .card h3 { margin-top: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

.stat-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-tile .value { font-size: 28px; font-weight: 700; color: var(--brand-dark); }
.stat-tile .label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat-tile.warn .value { color: var(--danger); }

/* ---------------- Forms ---------------- */
form.stacked { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row.two-col { flex-direction: row; gap: 16px; }
.form-row.two-col > * { flex: 1; }
label { font-size: 13px; font-weight: 600; color: #3a3f3d; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], select, textarea {
  border: 1px solid #cdd4d0; border-radius: 8px; padding: 9px 11px; font-size: 14px;
  font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { resize: vertical; min-height: 72px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row label { font-weight: 500; }
.hint { color: var(--muted); font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--brand); color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn.secondary { background: #fff; color: var(--brand-dark); border: 1px solid #bcd4c8; }
.btn.secondary:hover { background: var(--brand-light); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.danger { background: var(--danger); }
.btn.accent { background: var(--accent); }

/* ---------------- Tables ---------------- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th, table.data-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.data-table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
table.data-table tbody tr:hover { background: #fafcfb; }
table.data-table input[type=number] { width: 72px; padding: 5px 7px; }
.table-scroll { overflow-x: auto; }

/* ---------------- Badges ---------------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; }
.badge-open { background: #fdf1e0; color: #8a5a00; }
.badge-in_progress { background: #e3edfb; color: #1c4f9c; }
.badge-completed { background: var(--success-bg); color: var(--success); }
.badge-delivered { background: var(--brand-light); color: var(--brand-dark); }
.badge-cancelled { background: var(--danger-bg); color: var(--danger); }

/* Service Module v2 status badges (13-state flow) */
.badge-created, .badge-in_transit_to_shop { background: #fdf1e0; color: #8a5a00; }
.badge-received_at_shop, .badge-under_diagnosis, .badge-charging { background: #e3edfb; color: #1c4f9c; }
.badge-service_complete, .badge-billing_complete { background: #ede3fb; color: #5b2c9c; }
.badge-awaiting_payment { background: var(--danger-bg); color: var(--danger); }
.badge-ready_for_delivery, .badge-out_for_delivery { background: var(--brand-light); color: var(--brand-dark); }
.badge-delivered { background: var(--success-bg); color: var(--success); }
.badge-closed_sales_handoff { background: #ede3fb; color: #5b2c9c; }
.badge-cancelled { background: var(--danger-bg); color: var(--danger); }

/* Inventory Module v2: InventoryDay status + scrap register status */
.badge-submitted { background: var(--success-bg); color: var(--success); }
.badge-locked { background: var(--brand-light); color: var(--brand-dark); }
.badge-reopened { background: var(--danger-bg); color: var(--danger); }
.badge-held { background: #fdf1e0; color: #8a5a00; }
.badge-sent_to_manufacturer { background: #e3edfb; color: #1c4f9c; }
.badge-claim_settled { background: var(--success-bg); color: var(--success); }
.badge-disposed { background: #eee; color: #666; }

/* ---------------- Service Jobs: signature pad, scan input, dynamic rows ---------------- */
.signature-pad-wrap { border: 1px dashed var(--line); border-radius: 8px; background: #fff; touch-action: none; }
.signature-pad-wrap canvas { display: block; width: 100%; height: 160px; cursor: crosshair; }
.gps-status { font-size: 12.5px; padding: 6px 10px; border-radius: 6px; background: var(--brand-light); color: var(--brand-dark); display: inline-flex; align-items: center; gap: 6px; }
.gps-status.pending { background: #fdf1e0; color: #8a5a00; }
.gps-status.error { background: var(--danger-bg); color: var(--danger); }
.battery-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.battery-row { display: flex; gap: 8px; align-items: center; }
.battery-row input { flex: 1; }
.scan-input { font-size: 18px; padding: 12px 14px; font-family: 'SFMono-Regular', Consolas, monospace; }
.scan-feedback { min-height: 22px; font-size: 13.5px; font-weight: 600; margin-top: 6px; }
.scan-feedback.ok { color: var(--success); }
.scan-feedback.err { color: var(--danger); }
.qr-box { text-align: center; padding: 12px; }
.qr-box img { width: 160px; height: 160px; }
.qr-box .job-id-big { font-size: 20px; font-weight: 800; letter-spacing: .04em; margin-top: 6px; }
.job-group { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.job-group h4 { margin: 0 0 8px; }

/* ---------------- Alerts ---------------- */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13.5px; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #b9e2c9; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f0c2bd; }

/* ---------------- Login ---------------- */
.login-card {
  background: #fff; border-radius: 14px; padding: 36px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.login-card h1 { font-size: 20px; margin: 4px 0 2px; }
.login-card p.subtitle { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.login-logo .brand-mark { width: 36px; height: 36px; font-size: 15px; }

/* ---------------- Detail layout ---------------- */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .detail-grid { grid-template-columns: 1fr; } }
dl.info-list { display: grid; grid-template-columns: 130px 1fr; row-gap: 8px; column-gap: 10px; margin: 0; font-size: 13.5px; }
dl.info-list dt { color: var(--muted); }
dl.info-list dd { margin: 0; font-weight: 600; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.timeline li:last-child { border-bottom: none; }
.timeline .t-status { font-weight: 700; }
.timeline .t-meta { color: var(--muted); font-size: 12px; }

/* ---------------- Simple bar chart (no JS dependency) ---------------- */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-chart .bar { width: 100%; max-width: 26px; background: var(--brand); border-radius: 4px 4px 0 0; }
.bar-chart .bar.secondary { background: var(--accent); }
.bar-chart .bar-label { font-size: 10px; color: var(--muted); margin-top: 4px; writing-mode: vertical-rl; text-orientation: mixed; max-height: 60px; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.legend .dot.received { background: var(--brand); }
.legend .dot.sold { background: var(--accent); }

/* ---------------- Utility ---------------- */
.flex { display: flex; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); font-weight: 600; }
.text-right { text-align: right; }
.search-box { display: flex; gap: 8px; max-width: 520px; }
.search-box input { flex: 1; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ---------------- Print ---------------- */
@media print {
  .topbar, .app-footer, .page-actions, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: none; padding: 0; }
}
