/* ==========================================================================
   Saram Khel Coal Mine System — Public Portal styles
   Mobile-first. Dark navy blue + gold identity, matching the owner's
   dashboard mockup: navy sidebar (hexagon coal logo + system name + gold
   active menu item), clean white login card with logo on top, blue
   Sign In button, gold accents throughout.
   No external images — the mine-scene panel is pure CSS gradients.
   ========================================================================== */

:root {
  --navy-950: #050d1d;
  --navy-900: #0a1730;
  --navy-800: #10234a;
  --navy-700: #16305f;
  --navy-600: #1e3f78;
  --blue: #1d5fd1;
  --blue-dark: #1749a8;
  --blue-100: #dbe7fb;
  --blue-50: #eef3fc;
  --gold: #d4a017;
  --gold-light: #f0c94a;
  --gold-bright: #ffc93c;
  --gold-dark: #9a7a15;
  --ink: #1a2233;
  --muted: #5b6b82;
  --line: #dfe5ef;
  --bg: #f2f5fa;
  --card: #ffffff;
  --danger: #b3261e;
  --danger-bg: #fdeceb;
  --radius: 14px;
  --shadow-sm: 0 1px 3px rgba(5, 13, 29, .10);
  --shadow-md: 0 6px 18px rgba(5, 13, 29, .13);
  --shadow-lg: 0 18px 40px rgba(5, 13, 29, .22);
  --sidebar-w: 268px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--blue-dark); }
a:hover { color: var(--navy-900); }

/* ------------------------------------------------------------------ */
/* Top bar (mobile) / sidebar (desktop, per mockup)                    */
/* ------------------------------------------------------------------ */
#topbar {
  background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
  border-bottom: 2px solid var(--gold);
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; min-width: 0; }
.brand img {
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; object-fit: cover; flex: none;
  border: 2px solid var(--gold);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .4);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.brand-name2 { font-weight: 800; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--gold-light); white-space: nowrap; }
.brand-sub { font-size: 11px; color: #9fb0cc; letter-spacing: .04em; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex: none; }
.user-chip {
  font-size: 13px; background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  padding: 5px 10px; border-radius: 999px; white-space: nowrap;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}
.nav-scroll {
  max-width: 1100px; margin: 0 auto;
  display: flex; gap: 4px; overflow-x: auto;
  padding: 0 10px 8px;
  scrollbar-width: none;
}
.nav-scroll::-webkit-scrollbar { display: none; }
.nav-link {
  color: #c3d2ec; text-decoration: none; font-size: 13.5px; font-weight: 600;
  padding: 7px 12px; border-radius: 999px; white-space: nowrap; flex: none;
}
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.nav-link.active { color: #fff; background: var(--navy-600); box-shadow: inset 0 -2px 0 var(--gold); }

/* Desktop: the top bar becomes the mockup's navy sidebar. */
@media (min-width: 960px) {
  body { padding-left: var(--sidebar-w); }
  #topbar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    overflow-y: auto;
    border-bottom: 0;
    border-right: 2px solid var(--gold);
    box-shadow: 4px 0 18px rgba(0, 0, 0, .3);
  }
  .topbar-inner {
    flex-direction: column; align-items: stretch;
    padding: 24px 16px 10px; gap: 14px; max-width: none;
  }
  .brand { flex-direction: column; text-align: center; gap: 12px; }
  .brand img { width: 88px; height: 88px; border-width: 3px; }
  .brand-text { align-items: center; }
  .brand-name { font-size: 21px; }
  .brand-name2 { font-size: 13.5px; }
  .brand-sub { font-size: 11px; }
  .topbar-actions { margin-left: 0; justify-content: center; flex-wrap: wrap; }
  .user-chip { max-width: none; }
  .nav-scroll {
    flex-direction: column; overflow: visible;
    padding: 6px 14px 18px; gap: 4px; max-width: none;
  }
  .nav-link {
    padding: 10px 14px; border-radius: 10px;
    font-size: 14.5px; text-align: left;
  }
  .nav-link.active {
    background: linear-gradient(180deg, var(--gold-light), var(--gold));
    color: #241c00;
    box-shadow: 0 4px 12px rgba(212, 160, 23, .35), inset 0 1px 0 rgba(255, 255, 255, .5);
  }
}

/* ------------------------------------------------------------------ */
/* Layout                                                              */
/* ------------------------------------------------------------------ */
#view { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 14px 40px; }
#pagefoot { background: var(--navy-950); color: #93a5c4; font-size: 13px; }
.foot-inner { max-width: 1100px; margin: 0 auto; padding: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.foot-sep { color: var(--gold); }

.page-title { font-size: 22px; font-weight: 800; margin: 4px 0 2px; color: var(--navy-900); }
.page-sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.section-title { font-size: 16px; font-weight: 800; color: var(--navy-900); margin: 22px 0 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 14px;
}
.card h3 { margin: 0 0 8px; font-size: 15px; color: var(--navy-900); }
.muted { color: var(--muted); font-size: 13.5px; }
.small { font-size: 12.5px; }
.gold { color: var(--gold-dark); font-weight: 700; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 720px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow-sm);
}
.stat .num { font-size: 24px; font-weight: 800; color: var(--navy-900); line-height: 1.1; }
.stat .lbl { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat.gold-card { background: linear-gradient(160deg, #fff8dd, #fff); border-color: #ecd98a; }
.stat.gold-card .num { color: var(--gold-dark); }

.grid-2 { display: grid; gap: 14px; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ------------------------------------------------------------------ */
/* Buttons, forms                                                      */
/* ------------------------------------------------------------------ */
.btn {
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 15px;
  padding: 11px 18px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; min-height: 44px;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary {
  background: linear-gradient(180deg, #2b6fe0, var(--blue-dark));
  color: #fff; box-shadow: 0 4px 12px rgba(23, 73, 168, .4), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.btn-primary:hover { box-shadow: 0 6px 16px rgba(23, 73, 168, .5), inset 0 1px 0 rgba(255, 255, 255, .3); }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: #3a2f00; box-shadow: 0 4px 12px rgba(154, 122, 21, .35), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.btn-ghost { background: rgba(255, 255, 255, .12); color: #fff; border: 1px solid rgba(255, 255, 255, .25); }
.btn-outline { background: #fff; color: var(--navy-800); border: 1.5px solid var(--navy-700); box-shadow: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13.5px; min-height: 36px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.field { margin-bottom: 13px; }
.field label { display: block; font-weight: 700; font-size: 13.5px; margin-bottom: 5px; color: var(--navy-900); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .urdu { font-size: 12.5px; color: var(--muted); font-weight: 400; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 15.5px;
  padding: 11px 12px; border: 1.5px solid #c6d0e0; border-radius: 10px;
  background: #fff; color: var(--ink);
  min-height: 44px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 95, 209, .18);
}
input[readonly] { background: #f2f5fa; color: var(--muted); }
textarea { min-height: 80px; resize: vertical; }
.form-grid { display: grid; gap: 0 12px; }
@media (min-width: 640px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.search-input { max-width: 260px; }
select.inline { width: auto; min-height: 40px; padding: 8px 10px; font-size: 14px; }

/* ------------------------------------------------------------------ */
/* Tables                                                              */
/* ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
th {
  text-align: left; background: var(--navy-900); color: #fff;
  padding: 10px 12px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em;
  white-space: nowrap;
}
td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: var(--blue-50); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 800; background: #e8eef8; border-top: 2px solid var(--navy-700); }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.empty { padding: 26px 16px; text-align: center; color: var(--muted); }
.empty .big { font-size: 20px; font-weight: 700; color: var(--navy-900); margin-bottom: 4px; }

.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; font-size: 14px; }

.badge {
  display: inline-block; font-size: 12px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.badge-green { background: #d9ecdf; color: #0f5138; }
.badge-gold { background: #fdf3c4; color: var(--gold-dark); }
.badge-grey { background: #eceff1; color: var(--muted); }
.badge-red { background: var(--danger-bg); color: var(--danger); }

/* ------------------------------------------------------------------ */
/* Landing page — navy hero with CSS mine-scene panel                  */
/* ------------------------------------------------------------------ */
.hero {
  background: linear-gradient(180deg, #0e2247 0%, var(--navy-900) 55%, #071022 100%);
  border-radius: 20px; color: #fff; padding: 28px 20px; text-align: center;
  box-shadow: var(--shadow-lg); margin-bottom: 16px; position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% -20%, rgba(240, 201, 74, .4), transparent 60%);
  pointer-events: none;
}
/* Pure-CSS mine landscape: mountain ridges + terraced slopes + gold glow.
   No external images. */
.hero-scene { position: absolute; inset: 0; pointer-events: none; }
.hero-scene::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 58%;
  background: linear-gradient(180deg, #1b3a6e 0%, #12294f 100%);
  clip-path: polygon(0 100%, 0 58%, 10% 34%, 20% 54%, 30% 26%, 42% 52%, 54% 30%, 66% 56%, 78% 32%, 88% 52%, 100% 38%, 100% 100%);
  opacity: .9;
}
.hero-scene::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 36%;
  background:
    repeating-linear-gradient(115deg, rgba(212, 160, 23, .12) 0 14px, transparent 14px 30px),
    linear-gradient(180deg, #0d1f42 0%, var(--navy-950) 100%);
  clip-path: polygon(0 100%, 0 62%, 16% 30%, 32% 60%, 50% 26%, 66% 58%, 82% 32%, 100% 60%, 100% 100%);
}
.hero img.logo-hero {
  width: 110px; height: 110px; border-radius: 50%; background: #fff; object-fit: cover;
  border: 4px solid var(--gold); position: relative; z-index: 1;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .45), 0 0 0 8px rgba(255, 255, 255, .08);
}
.hero h1 { font-size: 26px; margin: 14px 0 4px; position: relative; z-index: 1; }
.hero-t1 { display: block; color: #fff; text-transform: uppercase; letter-spacing: .02em; }
.hero-t2 { display: block; color: var(--gold-light); text-transform: uppercase; letter-spacing: .04em; }
.hero p { margin: 0 auto 18px; max-width: 560px; color: #c3d2ec; position: relative; z-index: 1; }
.hero .btn-row { justify-content: center; position: relative; z-index: 1; }

.howto { counter-reset: step; }
.howto li { margin-bottom: 10px; }
.info-list { list-style: none; padding: 0; margin: 0; }
.info-list li { padding: 8px 0 8px 28px; position: relative; border-top: 1px solid var(--line); }
.info-list li:first-child { border-top: 0; }
.info-list li::before {
  content: "✓"; position: absolute; left: 2px; top: 8px;
  color: var(--blue); font-weight: 800;
}

/* ------------------------------------------------------------------ */
/* Login screen — white card, logo on top (mockup style)               */
/* ------------------------------------------------------------------ */
.login-stage {
  min-height: calc(100vh - 220px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 18px 0 8px;
  background:
    radial-gradient(600px 300px at 50% -60px, rgba(212, 160, 23, .25), transparent 70%),
    radial-gradient(800px 420px at 85% 0%, rgba(29, 95, 209, .16), transparent 60%);
}
.login-card {
  width: 100%; max-width: 440px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  border-radius: 22px;
  padding: 0 22px 24px;
  position: relative;
  border: 1px solid rgba(212, 160, 23, .45);
  /* Layered 3D depth: soft ambient + deep drop + gold rim light */
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .9) inset,
    0 24px 48px rgba(5, 13, 29, .28),
    0 4px 12px rgba(5, 13, 29, .18),
    0 0 0 1px rgba(255, 255, 255, .4);
  transform: perspective(900px) rotateX(1.2deg);
}
.login-card::before {
  content: ""; position: absolute; top: 0; left: 24px; right: 24px; height: 5px;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
  box-shadow: 0 2px 8px rgba(212, 160, 23, .5);
}
.login-logo-wrap { text-align: center; margin-top: -2px; padding-top: 22px; }
.login-logo {
  width: 104px; height: 104px; border-radius: 50%;
  object-fit: cover; background: #fff;
  border: 4px solid var(--gold);
  /* Raised 3D disc: ring + deep shadow + inner highlight */
  box-shadow:
    0 12px 24px rgba(5, 13, 29, .35),
    0 0 0 6px #fff,
    0 0 0 8px rgba(212, 160, 23, .35),
    inset 0 -6px 12px rgba(0, 0, 0, .12);
}
.login-title { text-align: center; font-size: 21px; font-weight: 800; color: var(--navy-900); margin: 14px 0 2px; }
.login-title .lt-main {
  display: block; font-size: 24px; font-weight: 800;
  color: var(--navy-900); letter-spacing: .02em; text-transform: uppercase;
}
.login-title .lt-sub {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 800; color: var(--gold);
  letter-spacing: .06em; text-transform: uppercase; margin-top: 2px;
}
.login-title .lt-sub::before,
.login-title .lt-sub::after {
  content: ""; flex: 1; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold));
}
.login-title .lt-sub::after { background: linear-gradient(90deg, var(--gold), transparent); }
.login-sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }

.tabs { display: flex; gap: 6px; background: #e9edf4; border-radius: 12px; padding: 5px; margin-bottom: 18px; }
.tab {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 14.5px; color: var(--muted);
  padding: 10px; border-radius: 9px; min-height: 42px;
}
.tab.active {
  background: linear-gradient(180deg, #fff, #f4f7fb);
  color: var(--navy-900);
  box-shadow: 0 3px 8px rgba(5, 13, 29, .18), inset 0 -2px 0 var(--gold);
}
.login-card input {
  box-shadow: inset 0 2px 4px rgba(5, 13, 29, .07);
  background: linear-gradient(180deg, #fbfcff, #fff);
}
.login-error {
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid #f3b8b4; border-radius: 10px;
  padding: 10px 12px; font-size: 14px; margin-bottom: 14px; font-weight: 600;
}
.login-note {
  background: var(--blue-50); border: 1px solid var(--blue-100);
  border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--navy-800);
  margin-top: 14px;
}
.link-btn {
  background: none; border: 0; color: var(--blue-dark); font: inherit; font-weight: 700;
  cursor: pointer; padding: 6px 2px; font-size: 14px; text-decoration: underline;
}

/* ------------------------------------------------------------------ */
/* Modal & toast                                                       */
/* ------------------------------------------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 12, 26, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 16px; z-index: 100; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  margin: 24px auto; box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 48px); display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 17px; margin: 0; color: var(--navy-900); }
.modal-x {
  border: 0; background: #eef2f8; width: 36px; height: 36px; border-radius: 50%;
  font-size: 18px; cursor: pointer; flex: none;
}
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px 16px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

#toast-root { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; width: min(92vw, 480px); }
.toast {
  background: var(--navy-950); color: #fff; border-radius: 12px;
  padding: 12px 16px; margin-top: 8px; font-size: 14.5px; font-weight: 600;
  box-shadow: var(--shadow-lg); border-left: 4px solid var(--gold);
}
.toast.error { background: #5c1410; border-left-color: #ff8a80; }

.code-display {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 30px; font-weight: 800; letter-spacing: .18em;
  text-align: center; background: #fff8dd; border: 2px dashed var(--gold);
  border-radius: 12px; padding: 14px; margin: 12px 0; color: var(--navy-900);
}

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14.5px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: 8px; } }

.loading { text-align: center; padding: 48px 16px; color: var(--muted); }
.loading .spin {
  width: 36px; height: 36px; margin: 0 auto 12px;
  border: 4px solid var(--blue-100); border-top-color: var(--blue);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ */
/* Print — production statement as a clean paper sheet                 */
/* ------------------------------------------------------------------ */
@media print {
  body { background: #fff; display: block; padding-left: 0; }
  #topbar, #pagefoot, #toast-root, #modal-root, .no-print { display: none !important; }
  #view { max-width: none; padding: 0; margin: 0; }
  .print-sheet { box-shadow: none !important; border: 0 !important; border-radius: 0 !important; }
  .print-sheet table { min-width: 0; }
}
.print-sheet { background: #fff; }
.print-sheet .sheet-head { text-align: center; border-bottom: 3px double var(--navy-900); padding-bottom: 10px; margin-bottom: 14px; }
.print-sheet .sheet-head img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold); }
.print-sheet .sheet-head h2 { margin: 6px 0 2px; font-size: 20px; color: var(--navy-900); }
.print-sheet .sheet-head p { margin: 0; color: var(--muted); font-size: 13px; }
