/* =====================================================================
   texicawine — stylesheet
   Identity: deep wine burgundy + warm parchment, serif display.
   ===================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=Spline+Sans+Mono:wght@400;500;600&display=swap');

:root {
  --wine:        #5b1a2b;
  --wine-deep:   #43101f;
  --wine-soft:   #7a2f43;
  --gold:        #c8a45c;
  --gold-soft:   #e7d3a3;
  --parchment:   #f6f1e7;
  --paper:       #fffdf8;
  --ink:         #2a2024;
  --ink-soft:    #6b5d62;
  --line:        #e6ddcf;
  --green:       #3f7d56;
  --green-bg:    #e7f1ea;
  --red:         #b23a3a;
  --red-bg:      #f7e7e5;
  --amber:       #b8821f;
  --amber-bg:    #f8efd9;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 1px 2px rgba(67,16,31,.05), 0 6px 24px rgba(67,16,31,.06);
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --serif:'Fraunces', Georgia, serif;
  --mono: 'Spline Sans Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--parchment);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--wine); text-decoration: none; }
h1,h2,h3,h4 { font-family: var(--serif); font-weight: 600; margin: 0 0 .4em; letter-spacing: -.01em; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--wine) 0%, var(--wine-deep) 100%);
  color: #f3e7da;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark { color: var(--gold); font-size: 22px; }
.brand-name { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: .01em; }

.nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: #e8d8c8; font-weight: 500; font-size: 14.5px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(200,164,92,.16); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav-icon { width: 22px; text-align: center; font-size: 15px; opacity: .9; }
.nav-label { flex: 1; }
.nav-badge {
  background: var(--gold); color: var(--wine-deep);
  font-size: 11px; font-weight: 700; border-radius: 20px;
  padding: 1px 7px; min-width: 20px; text-align: center;
}

.sidebar-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08);
}
.who { flex: 1; min-width: 0; }
.who-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-role { font-size: 12px; color: var(--gold-soft); }
.logout {
  color: #f3e7da; font-size: 18px; width: 36px; height: 36px;
  display: grid; place-items: center; border-radius: 8px;
  background: rgba(255,255,255,.06);
}
.logout:hover { background: rgba(255,255,255,.14); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 28px; background: var(--paper);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 22px; margin: 0; }
.menu-toggle { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--wine); }
.page { padding: 28px; max-width: 1240px; width: 100%; }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin-bottom: 22px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card-head h2 { margin: 0; font-size: 18px; }
.card-sub { color: var(--ink-soft); font-size: 13px; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::after { content:''; position:absolute; right:-20px; top:-20px; width:70px; height:70px; border-radius:50%; background: var(--gold-soft); opacity:.25; }
.stat-label { font-size: 12.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat-value { font-family: var(--serif); font-size: 28px; font-weight: 700; margin-top: 6px; color: var(--wine); }
.stat-value.mono { font-family: var(--mono); font-size: 24px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); font-weight: 600; }
table.data tbody tr:hover { background: var(--parchment); }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); }
.code { font-family: var(--mono); font-size: 13px; color: var(--wine-soft); font-weight: 500; }

/* product thumb */
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--parchment); border: 1px solid var(--line); }
.thumb.ph { display: grid; place-items: center; color: var(--ink-soft); font-size: 18px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.bad { background: var(--red-bg); color: var(--red); }
.badge.mute { background: var(--parchment); color: var(--ink-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
  background: var(--parchment); color: var(--ink); text-decoration: none;
}
.btn:hover { background: var(--line); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--wine); color: #fff; }
.btn-primary:hover { background: var(--wine-soft); }
.btn-gold { background: var(--gold); color: var(--wine-deep); }
.btn-gold:hover { background: #d4b573; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--parchment); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #f0d4d1; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  font-family: var(--sans); font-size: 14.5px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--wine-soft); box-shadow: 0 0 0 3px rgba(123,47,67,.12);
}
.field .hint { font-size: 12px; color: var(--ink-soft); }
.field.mono input { font-family: var(--mono); }
.checkline { display: flex; align-items: center; gap: 9px; }
.checkline input { width: auto; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; font-weight: 500; border: 1px solid transparent; }
.alert-success { background: var(--green-bg); color: var(--green); border-color: #bfe0cb; }
.alert-error   { background: var(--red-bg); color: var(--red); border-color: #eec6c2; }
.alert-info    { background: var(--amber-bg); color: var(--amber); border-color: #ecdcb0; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .spacer { flex: 1; }
.search { flex: 0 1 280px; }
.search input { width: 100%; padding: 9px 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty .big { font-size: 38px; opacity: .5; }

/* =====================================================================
   POS (Point of Sale)
   ===================================================================== */
.pos { display: grid; grid-template-columns: 1fr 380px; gap: 22px; align-items: start; }
.pos-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.pos-tab { padding: 8px 16px; border-radius: 20px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-weight: 600; font-size: 13.5px; }
.pos-tab.active { background: var(--wine); color: #fff; border-color: var(--wine); }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 12px; }
.pos-item {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; cursor: pointer; text-align: left; transition: border-color .15s, transform .05s;
  display: flex; flex-direction: column; gap: 4px;
}
.pos-item:hover { border-color: var(--wine-soft); }
.pos-item:active { transform: translateY(1px); }
.pos-item.out { opacity: .5; cursor: not-allowed; }
.pos-item .pi-img { width: 100%; height: 84px; border-radius: 8px; object-fit: cover; background: var(--parchment); margin-bottom: 4px; }
.pos-item .pi-img.ph { display: grid; place-items: center; font-size: 26px; color: var(--gold); }
.pos-item .pi-name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.pos-item .pi-price { font-family: var(--mono); color: var(--wine); font-weight: 600; font-size: 13.5px; }
.pos-item .pi-stock { font-size: 11.5px; color: var(--ink-soft); }

.cart { position: sticky; top: 90px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: calc(100vh - 120px); }
.cart-head { padding: 16px 18px; border-bottom: 1px solid var(--line); font-family: var(--serif); font-size: 18px; font-weight: 600; }
.cart-lines { flex: 1; overflow-y: auto; padding: 8px 12px; min-height: 80px; }
.cart-empty { text-align: center; color: var(--ink-soft); padding: 30px 10px; font-size: 14px; }
.cart-line { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.cl-name { flex: 1; min-width: 0; }
.cl-name .n { font-weight: 600; font-size: 13.5px; }
.cl-name .p { font-size: 12px; color: var(--ink-soft); font-family: var(--mono); }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line); background: var(--parchment); cursor: pointer; font-weight: 700; }
.qty span { min-width: 22px; text-align: center; font-family: var(--mono); font-weight: 600; }
.cl-total { width: 78px; text-align: right; font-family: var(--mono); font-weight: 600; font-size: 13px; }
.cl-del { color: var(--red); cursor: pointer; background: none; border: 0; font-size: 15px; }

.cart-foot { border-top: 1px solid var(--line); padding: 14px 18px; }
.sumline { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.sumline.total { font-family: var(--serif); font-size: 21px; font-weight: 700; color: var(--wine); border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 6px; }
.sumline .v { font-family: var(--mono); }
.mini-field { display: flex; gap: 8px; margin: 8px 0; }
.mini-field input, .mini-field select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; width: 100%; font-family: var(--sans); }

/* =====================================================================
   Receipt (printable)
   ===================================================================== */
.receipt { max-width: 360px; margin: 0 auto; background: #fff; padding: 26px 28px; border: 1px solid var(--line); border-radius: var(--radius); font-family: var(--mono); font-size: 13px; color: #222; }
.receipt h2 { font-family: var(--serif); text-align: center; margin: 0 0 2px; }
.receipt .r-sub { text-align: center; font-family: var(--sans); font-size: 12px; color: var(--ink-soft); margin-bottom: 14px; }
.receipt .r-meta { font-size: 12px; margin-bottom: 12px; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt table td { padding: 3px 0; vertical-align: top; }
.receipt .r-div { border-top: 1px dashed #bbb; margin: 10px 0; }
.receipt .r-total { font-weight: 700; font-size: 15px; }
.receipt .r-foot { text-align: center; font-family: var(--sans); font-size: 12px; color: var(--ink-soft); margin-top: 16px; }

/* =====================================================================
   Login
   ===================================================================== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--wine) 0%, var(--wine-deep) 100%); padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--paper); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.3); padding: 36px 32px; }
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .mark { font-size: 40px; color: var(--gold); }
.login-brand h1 { font-family: var(--serif); font-size: 30px; margin: 6px 0 2px; color: var(--wine); }
.login-brand p { color: var(--ink-soft); font-size: 13px; margin: 0; }

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

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .pos { grid-template-columns: 1fr; }
  .cart { position: static; max-height: none; }
}
@media (max-width: 780px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 100; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .form-grid { grid-template-columns: 1fr; }
  .page { padding: 18px; }
}

/* ---------- Helpers added for reports / users / settings ---------- */
.muted { color: var(--ink-soft); font-size: 13px; }
.card-title { font-family: var(--serif); font-size: 17px; margin: 0 0 12px; color: var(--wine); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 920px) { .grid-2 { grid-template-columns: 1fr; } }

/* role / status pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.admin { background: #efe2c4; color: #7a5a16; }
.pill.staff { background: #e7ecef; color: #44606e; }
.pill.active { background: #dff0e2; color: #2f7d46; }
.pill.disabled { background: #f0dede; color: #a23a3a; }

/* ---------- Texica logo in sidebar ---------- */
.brand-logo {
  display: block;
  width: 100%;
  max-width: 170px;
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}