/* =====================================================================
   Omni Credit Core — hand-crafted CSS (no Tailwind build step)
   Designed for Hostinger shared hosting: zero build chain.
   ===================================================================== */

:root {
  --bg:        #F8FAFC;
  --surface:   #FFFFFF;
  --border:    #E2E8F0;
  --border-2:  #F1F5F9;
  --muted:     #64748B;
  --muted-2:   #94A3B8;
  --text:      #0F172A;
  --text-2:    #1E293B;
  --accent:    #06B6D4;   /* cyan-500 */
  --accent-2:  #0891B2;   /* cyan-600 */
  --accent-bg: #ECFEFF;
  --success:   #10B981;
  --warning:   #F59E0B;
  --danger:    #EF4444;
  --purple:    #8B5CF6;
  --amber:     #F59E0B;
  --emerald:   #10B981;
  --radius:    14px;
  --radius-lg: 22px;
  --shadow:    0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 24px -12px rgba(15,23,42,0.18);
  --font:      "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:      "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- Layout shell ---------- */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #fff;
  border-right: 1px solid var(--border-2);
  padding: 20px 14px;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 18px 8px;
}
.sidebar__brand-mark {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff;
  font-weight: 700; font-size: 14px;
}
.sidebar__brand-name { font-weight: 700; letter-spacing: -0.01em; }
.sidebar__brand-sub  { font-size: 11px; color: var(--muted-2); }
.sidebar__section { font-size: 10px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.08em; margin: 16px 10px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  color: var(--muted); font-weight: 500; font-size: 13px;
  margin: 1px 0;
}
.nav-link:hover { background: var(--bg); color: var(--text-2); }
.nav-link.active { background: var(--accent-bg); color: var(--accent-2); }
.nav-link svg { width: 16px; height: 16px; }

.main { display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: #fff;
  border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
}
.topbar__title { font-weight: 600; font-size: 15px; }
.topbar__right { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #E0F2FE, #BAE6FD);
  color: var(--accent-2); display: grid; place-items: center;
  font-weight: 600; font-size: 12px;
}
.dropdown { position: relative; }
.dropdown__menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: #fff; border: 1px solid var(--border);
  border-radius: 10px; min-width: 200px; box-shadow: var(--shadow-md);
  padding: 6px; display: none; z-index: 50;
}
.dropdown.open .dropdown__menu { display: block; }
.dropdown__item {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; padding: 8px 10px;
  border-radius: 6px; font-size: 13px; color: var(--text);
}
.dropdown__item:hover { background: var(--bg); }

.content { padding: 24px 28px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---------- Page header ---------- */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.page-header p { color: var(--muted); margin: 4px 0 0; font-size: 13px; }

/* ---------- Grid + cards ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; transform: translateX(-100%); transition: transform 0.2s; width: 240px; z-index: 50; }
  .sidebar.open { transform: translateX(0); }
}

.card {
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 18px;
}
.card--flat { box-shadow: none; }
.card__title { font-size: 14px; font-weight: 600; margin: 0 0 12px; }

/* ---------- Metric card ---------- */
.metric { padding: 18px; border-radius: var(--radius-lg); background: #fff;
          border: 1px solid var(--border-2); box-shadow: var(--shadow); }
.metric__label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.metric__value { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.metric__icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; margin-bottom: 12px;
}
.metric__icon--cyan    { background: var(--accent-bg);  color: var(--accent-2); }
.metric__icon--purple  { background: #F3E8FF;           color: var(--purple); }
.metric__icon--amber   { background: #FEF3C7;           color: var(--amber); }
.metric__icon--emerald { background: #D1FAE5;           color: var(--emerald); }
.metric__icon--slate   { background: #F1F5F9;           color: var(--muted); }
.metric__icon svg      { width: 18px; height: 18px; }

/* ---------- Tables ---------- */
.table-wrap {
  background: #fff; border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead { background: #F8FAFC; }
.table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted-2); font-weight: 500; padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--border-2);
}
.table td {
  padding: 12px 16px; border-bottom: 1px solid var(--border-2); color: var(--text-2);
}
.table tbody tr { cursor: default; }
.table tbody tr.is-link { cursor: pointer; }
.table tbody tr.is-link:hover { background: #F0FDFF; }
.table .right { text-align: right; }
.table .mono  { font-family: var(--mono); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px; font-weight: 500; font-size: 13px;
  border: 1px solid transparent; transition: background 0.1s, border 0.1s;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-2); }
.btn--ghost { background: #fff; color: var(--text-2); border-color: var(--border); }
.btn--ghost:hover { background: var(--bg); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Inputs ---------- */
.field { display: block; margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.input, .select, .textarea {
  display: block; width: 100%; padding: 10px 12px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); transition: border 0.1s, box-shadow 0.1s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(6,182,212,0.15);
}
.input--search { padding-left: 36px; }
.search-wrap { position: relative; max-width: 360px; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted-2); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 500;
  border: 1px solid transparent;
}
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.badge--active     { background: #D1FAE5; color: #047857; }
.badge--suspended  { background: #FEE2E2; color: #B91C1C; }
.badge--expired    { background: #F1F5F9; color: var(--muted); }
.badge--lost       { background: #FEE2E2; color: #991B1B; }
.badge--trial      { background: #FEF3C7; color: #92400E; }
.badge--prepaid    { background: #ECFEFF; color: var(--accent-2); }
.badge--credit     { background: #F3E8FF; color: var(--purple); }
.badge--owner, .badge--admin   { background: #FEE2E2; color: #B91C1C; }
.badge--manager                 { background: #FEF3C7; color: #92400E; }
.badge--staff                   { background: #D1FAE5; color: #047857; }
.badge--viewer                  { background: #F1F5F9; color: var(--muted); }

/* ---------- Flash ---------- */
.flash-stack { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 10px 14px; border-radius: 10px; font-size: 13px;
  background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-md);
  min-width: 280px; max-width: 480px;
}
.flash--success { border-color: #A7F3D0; background: #ECFDF5; color: #047857; }
.flash--error   { border-color: #FECACA; background: #FEF2F2; color: #B91C1C; }
.flash--info    { border-color: #BAE6FD; background: #F0F9FF; color: #0369A1; }

/* ---------- Auth pages ---------- */
.auth-shell {
  min-height: 100vh; display: grid;
  grid-template-columns: 1fr 1.2fr;
}
@media (max-width: 800px) { .auth-shell { grid-template-columns: 1fr; } .auth-shell__side { display: none; } }
.auth-shell__form {
  display: flex; flex-direction: column; justify-content: center;
  padding: 48px 56px;
}
.auth-shell__form-inner { max-width: 380px; width: 100%; margin: 0 auto; }
.auth-shell__side {
  background: linear-gradient(135deg, #0F172A 0%, #1E3A8C 100%);
  color: #fff;
  display: flex; flex-direction: column; justify-content: center; padding: 56px;
  position: relative; overflow: hidden;
}
.auth-shell__side::before {
  content: ""; position: absolute; top: -120px; right: -120px;
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(6,182,212,0.25), rgba(6,182,212,0));
}
.auth-shell__side h2 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.auth-shell__side p { color: rgba(255,255,255,0.75); margin-top: 12px; }

/* ---------- Small utilities ---------- */
.row     { display: flex; align-items: center; gap: 12px; }
.row--between { justify-content: space-between; }
.row--wrap    { flex-wrap: wrap; }
.spacer  { flex: 1; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.text-muted   { color: var(--muted); }
.text-muted-2 { color: var(--muted-2); }
.text-right   { text-align: right; }
.text-mono    { font-family: var(--mono); }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }
.pill          { display: inline-flex; padding: 4px 10px; border-radius: 999px; font-size: 12px; background: #fff; border: 1px solid var(--border); color: var(--muted); }
.pill.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.divider { height: 1px; background: var(--border-2); margin: 16px 0; }
.empty   { padding: 48px 16px; text-align: center; color: var(--muted-2); font-size: 13px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  display: none; align-items: center; justify-content: center; z-index: 80;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px; max-width: 520px; width: calc(100% - 32px);
  padding: 24px; box-shadow: var(--shadow-md);
}
.modal__title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }

/* ---------- Brand chip on top sidebar (multi-tenant indicator) ---------- */
.tenant-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 8px; background: var(--bg);
  border: 1px solid var(--border-2); font-size: 12px; color: var(--muted);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tenant-chip__dot { width: 8px; height: 8px; border-radius: 50%; }

/* =====================================================================
   RESPONSIVE — comprehensive mobile/tablet support
   ===================================================================== */

/* Tables always horizontally scrollable on tight screens */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { min-width: 640px; }

/* Sidebar overlay backdrop on mobile
   IMPORTANT: position:fixed so it never takes a grid cell in .shell */
.sidebar-backdrop {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 49;
}
/* Show ONLY when the body has the sidebar-open class (toggled by JS) */
body.sidebar-open .sidebar-backdrop { display: block; }
/* On large screens (>900px) the sidebar is permanent — backdrop never shows */
@media (min-width: 901px) {
  .sidebar-backdrop { display: none !important; }
  body.sidebar-open .sidebar { transform: none; }  /* reset stale state */
}

/* --- Tablet (under 1024px) --- */
@media (max-width: 1024px) {
  .content { padding: 20px 18px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* --- Small tablet / large phone (under 900px) --- */
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }

  /* Sidebar slides in from the left */
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%); transition: transform 0.25s;
    width: 260px; z-index: 50;
    box-shadow: 2px 0 16px rgba(15,23,42,0.18);
  }
  .sidebar.open { transform: translateX(0); }

  /* Show the hamburger button on mobile (button only — NOT the backdrop div) */
  button[data-sidebar-toggle] { display: inline-flex !important; }

  /* Topbar: keep title visible, drop sub-labels in user dropdown trigger */
  .topbar { padding: 0 14px; height: 56px; }
  .topbar__title { font-size: 14px; }
  .topbar .dropdown > button > div { display: none; }

  .content { padding: 16px 14px; }
  .page-header { margin-bottom: 14px; }
  .page-header h1 { font-size: 20px; }
}

/* --- Phone (under 640px) --- */
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid { gap: 12px; }

  /* page header: stack title and action button */
  .page-header.row, .page-header .row--between { flex-wrap: wrap; gap: 12px; }
  .page-header h1 { font-size: 18px; }

  /* row utility wraps */
  .row--between { flex-wrap: wrap; gap: 10px; }

  /* search bar full width */
  .search-wrap { max-width: 100% !important; }

  /* card padding tighter */
  .card { padding: 14px; border-radius: 16px; }
  .metric { padding: 14px; }
  .metric__value { font-size: 18px; }

  /* buttons full-width when used as the only action in a card form */
  .card form > .row[style*="flex-end"] { width: 100%; }
  .card form > .row[style*="flex-end"] .btn { flex: 1; min-width: 0; }

  /* flash messages stretch to viewport */
  .flash-stack { left: 12px; right: 12px; top: 12px; }
  .flash { min-width: 0; max-width: 100%; }

  /* table cells more compact */
  .table th, .table td { padding: 10px 12px; font-size: 12px; }
}

/* --- POS TERMINAL responsive --- */
@media (max-width: 700px) {
  .term-body { padding: 14px !important; }
  .term-card { padding: 16px !important; }
  .term-card h2 { font-size: 12px; }

  /* step pills: hide labels, keep numbered circles */
  .step-pill__lbl { display: none; }
  .step-pill { padding: 6px 8px; }

  /* keypad keys bigger for thumbs */
  .keypad button { padding: 22px 0 !important; font-size: 22px !important; }

  .term-display { font-size: 24px !important; letter-spacing: 0.04em !important; }
  .term-display--small { font-size: 20px !important; }

  .term-top { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .term-top__brand span:nth-child(3) { display: none; }   /* hide device meta */
}

/* --- Auth pages on mobile --- */
@media (max-width: 800px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-shell__side { display: none; }
  .auth-shell__form { padding: 32px 24px; }
}

/* --- Print (already partly defined in terminal layout, this is global) --- */
@media print {
  .sidebar, .topbar, .flash-stack { display: none !important; }
  .shell { grid-template-columns: 1fr !important; }
  .content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}
