﻿@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #111111;
  --ink-soft: #5F5F5F;
  --paper: #F7F7F5;
  --card: #FFFFFF;
  --line: #E2E2DE;
  --line-strong: #C9C9C2;

  --teal: #B88918;
  --teal-dark: #8A6812;

  --amber: #D4A72C;
  --amber-bg: #FFF8E1;

  --red: #C62828;
  --red-bg: #FDECEC;

  --radius: 6px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'IBM Plex Mono', monospace; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: 0.95rem; }
a { color: inherit; }
.hidden { display: none !important; }

.btn {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:hover { opacity: 0.85; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line-strong); }
.btn.secondary:hover { background: rgba(0,0,0,0.03); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
.field label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-soft); font-weight: 600;
}
.field input, .field select {
  padding: 0.55rem 0.7rem; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(47,111,94,0.15);
}

.error-msg {
  background: var(--red-bg); color: var(--red); border: 1px solid var(--red);
  padding: 0.6rem 0.8rem; border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 0.8rem;
}
.success-msg {
  background: #E4F0EA; color: var(--teal-dark); border: 1px solid var(--teal);
  padding: 0.6rem 0.8rem; border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 0.8rem;
}

/* ---------- Login screen ---------- */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem;
  background:
    repeating-linear-gradient(180deg, transparent, transparent 27px, var(--line) 28px),
    var(--paper);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 2.2rem 2rem 2rem; box-shadow: 0 12px 30px rgba(28, 43, 36, 0.10);
  position: relative;
}
.login-card::before {
  content: ''; position: absolute; top: -1px; left: 24px; right: 24px; height: 6px;
  background: repeating-linear-gradient(90deg, var(--teal) 0 10px, transparent 10px 16px);
  border-radius: 0 0 3px 3px;
}
.login-brand-eyebrow {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.7rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--teal-dark); margin: 0 0 0.3rem;
}
.login-card h1 { font-size: 1.5rem; margin: 0 0 0.2rem; letter-spacing: -0.01em; }
.login-card .sub { font-size: 0.85rem; color: var(--ink-soft); margin: 0 0 1.6rem; }
.login-card form { margin-top: 0.4rem; }
.login-card .btn { width: 100%; margin-top: 0.4rem; padding: 0.7rem; }
.login-hint {
  margin-top: 1.4rem; font-size: 0.75rem; color: var(--ink-soft);
  border-top: 1px dashed var(--line-strong); padding-top: 0.9rem;
}
.login-hint code {
  background: var(--paper); padding: 0.1rem 0.35rem; border-radius: 3px;
  font-family: 'IBM Plex Mono', monospace;
}

/* ---------- App shell ---------- */
#app-screen { display: none; min-height: 100vh; grid-template-columns: 240px 1fr; }
#app-screen.active { display: grid; }

.sidebar { background: var(--ink); color: var(--paper); padding: 1.4rem 1.1rem; display: flex; flex-direction: column; }
.sidebar-brand {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.68rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: #9CB2A6; margin-bottom: 0.2rem;
}
.sidebar-title { font-size: 1.15rem; font-weight: 700; margin: 0 0 1.1rem; letter-spacing: -0.01em; }

.shop-tag {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.55rem 0.65rem; border: 1px dashed rgba(255,255,255,0.25);
  border-radius: 3px; font-size: 0.75rem; margin-bottom: 1.6rem;
}
.shop-tag .name { font-weight: 600; }
.shop-tag .cat { color: #9CB2A6; font-size: 0.68rem; }

nav.main-nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
nav.main-nav button {
  text-align: left; background: transparent; border: none; color: #CBD8CF;
  padding: 0.6rem 0.7rem; border-radius: 3px; font-size: 0.88rem; font-weight: 500;
  display: flex; align-items: center; gap: 0.6rem;
}
nav.main-nav button:hover { background: rgba(255,255,255,0.06); color: #fff; }
nav.main-nav button.active { background: var(--teal); color: #fff; }
nav.main-nav .badge {
  margin-left: auto; background: var(--amber); color: #2A1B00; font-size: 0.68rem;
  font-weight: 700; border-radius: 10px; padding: 0.05rem 0.45rem;
}

.sidebar-footer { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.12); }
.who { font-size: 0.82rem; margin-bottom: 0.6rem; }
.who .role-tag {
  display: inline-block; font-family: 'IBM Plex Mono', monospace; font-size: 0.62rem;
  letter-spacing: 0.06em; text-transform: uppercase; background: rgba(255,255,255,0.1);
  padding: 0.1rem 0.4rem; border-radius: 3px; margin-top: 0.15rem;
}

.main-panel { padding: 1.8rem 2.4rem 3rem; overflow-y: auto; max-height: 100vh; }

.panel-header {
  display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.4rem;
  padding-bottom: 0.9rem; border-bottom: 1px dashed var(--line-strong);
}
.panel-header h2 { margin: 0; font-size: 1.4rem; letter-spacing: -0.01em; }
.panel-header .desc { font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.2rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.9rem; margin-bottom: 1.8rem; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; position: relative; }
.stat-card .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); font-weight: 600; }
.stat-card .value { font-family: 'IBM Plex Mono', monospace; font-size: 1.7rem; font-weight: 600; margin-top: 0.3rem; }
.stat-card.alert { border-color: var(--amber); background: var(--amber-bg); }
.stat-card.alert .value { color: #7A4A0F; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; margin-bottom: 1.5rem; }
.card h3 { margin: 0 0 1rem; font-size: 1rem; display: flex; align-items: center; gap: 0.5rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
  text-align: left; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-soft); border-bottom: 1px solid var(--line-strong); padding: 0.5rem 0.6rem; font-weight: 600;
}
tbody td { padding: 0.6rem 0.6rem; border-bottom: 1px solid var(--line); }
tbody tr:hover { background: rgba(47,111,94,0.04); }
.num { font-family: 'IBM Plex Mono', monospace; text-align: right; }
.empty-row td { text-align: center; color: var(--ink-soft); padding: 1.6rem; font-style: italic; }

.pill { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 10px; font-size: 0.72rem; font-weight: 600; }
.pill.ok { background: #E4F0EA; color: var(--teal-dark); }
.pill.low { background: var(--amber-bg); color: #7A4A0F; }
.pill.off { background: var(--red-bg); color: var(--red); }

.bin-chip {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.72rem; border: 1px dashed var(--line-strong);
  border-radius: 3px; padding: 0.1rem 0.45rem; background: var(--paper);
}

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.9rem; align-items: end; }
.filter-row { display: flex; gap: 0.8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-row .field { margin-bottom: 0; min-width: 160px; }

.feed-item { display: flex; gap: 0.8rem; padding: 0.7rem 0; border-bottom: 1px dashed var(--line); font-size: 0.85rem; }
.feed-item:last-child { border-bottom: none; }
.feed-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); margin-top: 0.35rem; flex-shrink: 0; }
.feed-item.low .dot { background: var(--amber); }
.feed-item .meta { color: var(--ink-soft); font-size: 0.75rem; margin-top: 0.15rem; }

.top-actions { display: flex; gap: 0.6rem; align-items: center; }

@media (max-width: 860px) {
  #app-screen.active { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .main-panel { padding: 1.2rem; }
}

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ============================================================
   MK COMPUTERS - MULTI DEVICE RESPONSIVE DESIGN
   Phones, tablets, iPads, laptops, desktops and MacBooks
   ============================================================ */

/* Prevent inputs and cards from overflowing */
* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

img,
video {
  max-width: 100%;
  height: auto;
}

/* Tables become horizontally scrollable on small screens */
.card {
  overflow-x: auto;
}

.card > h3,
.card > form,
.card > .form-row,
.card > .filter-row {
  min-width: 0;
}

table {
  min-width: 620px;
}

/* Better touch targets */
button,
select,
input,
textarea {
  max-width: 100%;
}

button {
  min-height: 40px;
}

input,
select,
textarea {
  min-height: 40px;
}

/* ---------- Tablets ---------- */
@media (max-width: 1024px) {
  #app-screen {
    grid-template-columns: 210px 1fr;
  }

  .sidebar {
    padding: 1.1rem 0.8rem;
  }

  .main-panel {
    padding: 1.4rem 1.5rem 2.5rem;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-header {
    align-items: flex-start;
    gap: 1rem;
  }
}

/* ---------- Phones and small tablets ---------- */
@media (max-width: 700px) {

  #app-screen.active {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }

  /* Compact mobile header/sidebar */
  .sidebar {
    width: 100%;
    padding: 0.85rem;
    display: block;
  }

  .sidebar-brand {
    font-size: 0.62rem;
  }

  .sidebar-title {
    font-size: 1rem;
    margin-bottom: 0.7rem;
  }

  .shop-tag {
    margin-bottom: 0.8rem;
  }

  /* Navigation becomes horizontal and scrollable */
  nav.main-nav {
    display: flex;
    flex-direction: row;
    gap: 0.35rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.35rem;
    flex: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  nav.main-nav button {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0.6rem 0.75rem;
    font-size: 0.8rem;
  }

  .sidebar-footer {
    margin-top: 0.7rem;
    padding-top: 0.7rem;
  }

  .who {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .sidebar-footer .btn {
    width: 100% !important;
  }

  .main-panel {
    width: 100%;
    padding: 1rem 0.8rem 2rem;
    overflow-y: visible;
    max-height: none;
  }

  .panel-header {
    display: block;
    margin-bottom: 1rem;
  }

  .panel-header h2 {
    font-size: 1.2rem;
  }

  .panel-header .desc {
    font-size: 0.78rem;
  }

  /* Dashboard cards */
  .stat-grid {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .stat-card {
    padding: 0.9rem;
  }

  .stat-card .value {
    font-size: 1.45rem;
  }

  /* Forms stack vertically */
  .form-row {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .field {
    width: 100%;
  }

  .field input,
  .field select,
  .field textarea {
    width: 100%;
  }

  .filter-row {
    flex-direction: column;
    gap: 0.6rem;
  }

  .filter-row .field {
    width: 100%;
    min-width: 0;
  }

  .filter-row select {
    width: 100%;
  }

  /* Cards */
  .card {
    padding: 0.9rem;
    margin-bottom: 1rem;
  }

  .card h3 {
    font-size: 0.95rem;
  }

  /* Keep tables usable by scrolling */
  .card table {
    min-width: 650px;
  }

  /* Profit selector */
  #dashboard-profit-period {
    min-width: 110px;
    width: auto;
  }

  /* Buttons are easier to tap */
  .btn {
    min-height: 42px;
  }

  .btn.small {
    min-height: 38px;
  }

  /* Recent sales feed */
  .feed-item {
    font-size: 0.8rem;
    gap: 0.6rem;
  }
}

/* ---------- Very small phones ---------- */
@media (max-width: 420px) {

  .sidebar {
    padding: 0.7rem;
  }

  .shop-tag {
    font-size: 0.68rem;
  }

  nav.main-nav button {
    font-size: 0.75rem;
    padding: 0.55rem 0.65rem;
  }

  .main-panel {
    padding: 0.8rem 0.6rem 1.5rem;
  }

  .stat-card .value {
    font-size: 1.3rem;
  }

  .stat-card {
    padding: 0.8rem;
  }

  .card {
    padding: 0.75rem;
  }

  #dashboard-profit-period {
    min-width: 100px;
    font-size: 0.78rem;
  }
}

/* ---------- Landscape phones ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  .sidebar {
    padding: 0.6rem 0.8rem;
  }

  .sidebar-footer {
    margin-top: 0.4rem;
  }

  .main-panel {
    padding-top: 0.8rem;
  }
}

/* ---------- Touch devices ---------- */
@media (hover: none) and (pointer: coarse) {
  nav.main-nav button,
  button,
  select,
  input {
    min-height: 44px;
  }

  nav.main-nav {
    -webkit-overflow-scrolling: touch;
  }
}
/* ---------- Sales Summary - compact ---------- */
.sales-summary-compact .stat-grid {
  gap: 0.6rem;
}

.sales-summary-compact .stat-card {
  padding: 0.7rem 0.8rem;
}

.sales-summary-compact .stat-card .label {
  font-size: 0.65rem;
}

.sales-summary-compact .stat-card .value {
  font-size: 1rem;
  margin-top: 0.15rem;
}
/* FORCE COMPACT SALES SUMMARY */
.card.sales-summary-compact .stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0;
}

.card.sales-summary-compact .stat-card {
  padding: 0.55rem 0.7rem;
  min-height: 0;
}

.card.sales-summary-compact .stat-card .label {
  font-size: 0.62rem;
  line-height: 1.2;
}

.card.sales-summary-compact .stat-card .value {
  font-size: 1rem !important;
  line-height: 1.2;
  margin-top: 0.15rem;
}
/* ---------- MK COMPUTERS title ---------- */
.system-subtitle {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  margin: 0.15rem 0 0;
  color: var(--ink-soft);
}

/* ---------- Professional Store Switcher ---------- */
#store-switcher {
  margin: 14px 0 18px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 10px;
  background: rgba(255,255,255,.04);
}

#store-switcher label {
  display: block;
  margin-bottom: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .65;
}

#store-selector {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  background: #18212b;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

#store-selector:hover {
  border-color: rgba(255,255,255,.28);
}

#store-selector:focus {
  border-color: #6b8afd;
  box-shadow: 0 0 0 3px rgba(107,138,253,.15);
}

#store-selector:disabled {
  opacity: .6;
  cursor: wait;
}
