/*
  MAPPHEX – Director ERP UI
  (Front-end prototype styling; connect backend auth/DB for production.)
*/

:root {
  --bg: #06101f;
  --panel: rgba(17, 11, 8, 0.64);
  --panel-2: rgba(35, 23, 16, 0.72);
  --border: rgba(173, 122, 82, 0.20);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.70);
  --muted-2: rgba(255, 255, 255, 0.55);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.30);
  --radius: 18px;
  --radius-sm: 12px;
  --accent: #0077ff;
  --accent-2: #5bd6ff;
  --danger: #fb7185;
  --ok: #38bdf8;
  --warn: #fbbf24;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial,
    "Noto Sans", "Liberation Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  scrollbar-gutter: stable;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  min-width: 320px;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1100px 650px at 18% -10%, rgba(0, 119, 255, 0.36), transparent 55%),
    radial-gradient(900px 520px at 92% 10%, rgba(91, 214, 255, 0.24), transparent 52%),
    radial-gradient(800px 500px at 50% 115%, rgba(148, 163, 184, 0.16), transparent 55%),
    linear-gradient(180deg, var(--bg), #070a14 72%);
}

a {
  color: inherit;
  text-decoration: none;
}

.muted {
  color: var(--muted);
}

.small-note {
  margin: 14px 2px 0;
  font-size: 12px;
  color: var(--muted-2);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(35, 23, 16, 0.64);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  background: rgba(55, 35, 24, 0.78);
  border-color: rgba(211, 154, 103, 0.32);
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  border-color: rgba(0, 119, 255, 0.58);
  background: linear-gradient(135deg, rgba(0, 119, 255, 0.95), rgba(91, 214, 255, 0.68));
}

.btn.primary:hover {
  border-color: rgba(91, 214, 255, 0.85);
  filter: brightness(1.04);
}

.btn.danger {
  border-color: rgba(251, 113, 133, 0.55);
  background: rgba(251, 113, 133, 0.10);
}

.btn.danger:hover {
  border-color: rgba(251, 113, 133, 0.85);
  background: rgba(251, 113, 133, 0.14);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.10);
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.10);
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
}

.pill.offline {
  border-color: rgba(251, 113, 133, 0.35);
  background: rgba(251, 113, 133, 0.10);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  background: rgba(8, 11, 22, 0.62);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 220px;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.3px;
  background: linear-gradient(135deg, rgba(0, 119, 255, 0.95), rgba(91, 214, 255, 0.75));
  box-shadow: var(--shadow-soft);
}

.logo-img {
  width: 56px;
  height: 42px;
  object-fit: contain;
  border-radius: 10px;
  display: block;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.brand-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.brand-subtitle {
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.layout {
  width: min(1180px, calc(100% - 40px));
  margin: 22px auto 44px;
  display: grid;
  gap: 16px;
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}

.panel-header {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(173, 122, 82, 0.18);
  background: linear-gradient(180deg, rgba(55, 35, 24, 0.70), rgba(23, 16, 12, 0.36));
}

.panel-header h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.2px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.kpis {
  padding: 16px 18px 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: var(--panel-2);
  border-radius: 16px;
  padding: 14px 14px 12px;
  min-height: 98px;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
}

.kpi-value {
  font-size: 26px;
  font-weight: 850;
  margin-top: 8px;
  letter-spacing: 0.4px;
}

.kpi-foot {
  font-size: 12px;
  margin-top: 6px;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.12);
}

input[type="search"],
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
.field input,
textarea,
select {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  outline: none;
  transition: border-color 120ms ease, background 120ms ease;
}

input[type="search"]:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
.field input:focus,
textarea:focus,
select:focus {
  border-color: rgba(34, 211, 238, 0.55);
  background: rgba(0, 0, 0, 0.22);
}

textarea {
  resize: vertical;
}

/* Generic panel collapse helper */
.panel.collapsed .panel-body {
  display: none;
}

.inline-field input[type="search"] {
  padding: 8px 10px;
  border-radius: 999px;
  border-color: rgba(255, 255, 255, 0.12);
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-size: 12px;
  color: var(--muted);
}

.table-wrap {
  padding: 10px 12px 14px;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* Inventory panel collapse */
#inventory-panel.collapsed .table-wrap {
  display: none;
}

#inventory-panel.collapsed .inline-field {
  display: none;
}

#inventory-panel.collapsed .panel-header {
  border-bottom: none;
}

.table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
}

.accounts-table-wrap {
  max-width: 100%;
}

.accounts-table-wrap .table {
  min-width: 980px;
}

.accounts-table-wrap .report-buttons {
  min-width: 250px;
  justify-content: flex-start;
}

.table thead th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.04);
}

.table tbody td {
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

.table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.035);
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.report-controls {
  padding: 14px 18px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.report-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.report-buttons .btn {
  white-space: nowrap;
}

.reports-drawer {
  padding: 14px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.03);
}

.reports-drawer-grid {
  display: grid;
  gap: 14px;
}

.reports-drawer-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.2px;
  margin-bottom: 10px;
}

.reports-drawer-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.report-output {
  margin: 0 18px 18px;
  padding: 14px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.14);
  min-height: 68px;
  overflow-x: auto;
}

.report-details {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 16px;
  padding: 12px 12px;
}

.report-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
}

.report-summary::-webkit-details-marker {
  display: none;
}

.report-summary .btn {
  pointer-events: none;
  padding: 8px 12px;
  border-radius: 999px;
}

.report-output h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.report-output p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 13px;
}

.branch-form {
  padding: 14px 18px 6px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.charts-grid {
  padding: 14px 18px 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.chart-card {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  padding: 14px 14px;
}

canvas {
  width: 100%;
  display: block;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.report-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.report-card {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  padding: 12px 12px;
}

.report-card .label {
  font-size: 12px;
  color: var(--muted);
}

.report-card .value {
  font-size: 18px;
  font-weight: 850;
  margin-top: 6px;
}

.dept-grid {
  padding: 14px 18px 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.dept-card {
  display: block;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  padding: 14px 14px;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.dept-card:hover {
  transform: translateY(-2px);
  border-color: rgba(34, 211, 238, 0.40);
  background: rgba(255, 255, 255, 0.07);
}

.dept-title {
  font-weight: 850;
  letter-spacing: 0.2px;
  margin-bottom: 6px;
}

/* Auth */
.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.auth-card {
  width: min(460px, 100%);
  max-width: 100%;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow);
  padding: 18px 18px 14px;
}

.auth-header h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.2px;
}

.auth-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-form {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}

.hint {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.12);
  padding: 10px 12px;
}

.hint summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.hint p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 0;
  font-size: 12px;
}

.auth-footer .btn {
  border: 0;
  box-shadow: none;
}

label.remember-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(0, 0, 0, 0.12);
}

label.remember-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-2);
}

/* Toast */
.toast {
  position: fixed;
  inset: auto 18px 18px auto;
  background: rgba(10, 12, 22, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow-soft);
  color: var(--text);
  padding: 12px 12px;
  border-radius: 14px;
  max-width: 320px;
  backdrop-filter: blur(10px);
}

.toast .t-title {
  font-weight: 800;
  font-size: 13px;
  margin: 0 0 4px;
}

.toast .t-body {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.site-powered-footer {
  width: min(1180px, calc(100% - 40px));
  margin: 10px auto 18px;
  padding: 12px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
}

/* Responsive */
@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
  }
  .brand {
    min-width: 0;
  }
  .topbar-actions {
    max-width: 100%;
  }
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dept-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .report-controls {
    grid-template-columns: 1fr;
  }
  .report-buttons {
    justify-content: flex-start;
  }
  .branch-form {
    grid-template-columns: 1fr;
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
  .table {
    min-width: 720px;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 14px 14px;
    position: relative;
    flex-direction: column;
    align-items: stretch;
  }
  .layout {
    width: calc(100% - 20px);
    margin-top: 12px;
  }
  .brand {
    width: 100%;
  }
  .brand-title {
    font-size: 13px;
  }
  .brand-subtitle {
    font-size: 11px;
  }
  .topbar-actions {
    justify-content: flex-start;
  }
  .topbar-actions .btn,
  .topbar-actions .badge {
    min-height: 38px;
  }
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .panel-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .panel-actions .btn,
  .report-buttons .btn {
    flex: 1 1 auto;
    min-width: 120px;
  }
  .auth-shell {
    place-items: center;
    padding: 18px 10px;
  }
  .auth-card {
    border-radius: 16px;
  }
  .report-grid {
    grid-template-columns: 1fr;
  }
  .dept-grid {
    grid-template-columns: 1fr;
  }
  .kpis {
    grid-template-columns: 1fr;
  }
  .table-wrap {
    padding: 8px 8px 12px;
  }
  .table {
    min-width: 680px;
  }
  .accounts-table-wrap .table {
    min-width: 900px;
  }
  .report-output {
    margin: 0 10px 14px;
    padding: 10px;
  }
}

/* Enterprise responsive hardening */
img,
svg,
video,
canvas {
  max-width: 100%;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

.btn,
.icon-btn,
button,
input,
select {
  touch-action: manipulation;
}

.topbar {
  min-height: 72px;
}

.topbar-actions {
  min-width: 0;
}

.layout,
.panel,
.kpi,
.table-wrap {
  min-width: 0;
}

.panel {
  contain: layout paint;
}

@media (max-width: 760px) {
  body {
    background:
      radial-gradient(520px 320px at 18% -10%, rgba(0, 119, 255, 0.2), transparent 64%),
      linear-gradient(180deg, var(--bg), #070a14 72%);
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 12px;
    flex-wrap: wrap;
    align-items: center;
  }

  .brand {
    flex: 1 1 100%;
    min-width: 0;
  }

  .brand-title,
  .brand-subtitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .topbar-actions .btn,
  .topbar-actions .badge,
  .panel-actions .btn,
  .auth-form .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  .layout {
    width: calc(100% - 20px);
    margin: 12px auto 28px;
    gap: 12px;
  }

  .panel {
    border-radius: 16px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.24);
    contain: layout paint;
  }

  .panel-header {
    padding: 14px;
    display: grid;
    align-items: start;
  }

  .panel-actions {
    width: 100%;
    justify-content: stretch;
  }

  .kpis {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .kpi {
    min-height: 86px;
  }

  .table-wrap {
    padding: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .table {
    min-width: 680px;
  }

  input[type="search"],
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  textarea,
  select {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  .btn:hover,
  .dept-card:hover {
    transform: none;
  }

  .toast,
  .enterprise-status,
  .enterprise-notice {
    backdrop-filter: none;
  }
}

@media (max-width: 420px) {
  .topbar-actions {
    grid-template-columns: 1fr;
  }

  .logo-img {
    width: 48px;
    height: 38px;
  }

  .toast {
    inset: auto 10px 10px 10px;
    max-width: none;
  }
}
