/* Digi Food ERP - simple responsive styles */

[hidden] { display: none !important; }

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e3e6ea;
  --brand: #e2571f;
  --brand-dark: #c44715;
  --income: #14804a;
  --income-bg: #e6f5ec;
  --expense: #c02626;
  --expense-bg: #fdeaea;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- Header / nav ---------- */

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 12px;
  padding-bottom: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  color: var(--brand);
}
.brand:hover { text-decoration: none; }

.brand .logo {
  display: inline-flex;
  align-items: center;
}

.logo img {
  height: 32px;
  width: auto;
  display: block;
  border-radius: 6px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-install {
  background: var(--text);
  border-color: var(--text);
  padding: 8px 14px;
  min-height: 40px;
  font-size: 14px;
  border-radius: 8px;
  margin-left: auto;
}
.btn-install:hover { background: #000; border-color: #000; }

.offline-banner {
  background: var(--expense);
  color: #fff;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
}

.offline-card { max-width: 560px; margin: 24px auto; text-align: center; }
.offline-card .form-actions { justify-content: center; }

.main-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.main-nav a {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
}

.main-nav a:hover {
  background: var(--bg);
  text-decoration: none;
  color: var(--text);
}

.main-nav a.active {
  background: var(--brand);
  color: #fff;
}

/* ---------- Main ---------- */

main.container {
  padding-top: 20px;
  padding-bottom: 40px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

h1 {
  font-size: 22px;
  margin: 0;
}

h2 {
  font-size: 17px;
  margin: 0 0 12px;
}

.section { margin-top: 24px; }

.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- Flash messages ---------- */

.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 15px;
  border: 1px solid transparent;
}

.flash-success { background: var(--income-bg); color: var(--income); border-color: #bfe6d0; }
.flash-error   { background: var(--expense-bg); color: var(--expense); border-color: #f3c9c9; }

.flash-close {
  background: none;
  border: 0;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: .6;
  padding: 0 2px;
}
.flash-close:hover { opacity: 1; }

/* ---------- Cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card h2 { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .04em; }

.stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.stat:last-child { border-bottom: 0; padding-bottom: 0; }
.stat .label { color: var(--muted); font-size: 15px; }
.stat .value { font-weight: 700; font-variant-numeric: tabular-nums; }

.value.income  { color: var(--income); }
.value.expense { color: var(--expense); }
.value.net.pos { color: var(--income); }
.value.net.neg { color: var(--expense); }

/* ---------- Quick actions ---------- */

.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  text-align: center;
}

.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; }

.btn-outline {
  background: var(--card);
  color: var(--brand);
}
.btn-outline:hover { background: #fff5f0; color: var(--brand-dark); }

.btn-block { width: 100%; }

/* ---------- Filters ---------- */

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}

.filters a {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.filters a:hover { text-decoration: none; color: var(--text); }
.filters a.active { background: var(--text); border-color: var(--text); color: #fff; }

.date-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}

/* ---------- Tables ---------- */

.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th, td {
  padding: 12px 14px;
  text-align: left;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  background: #fafbfc;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
}

tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}
.badge.income  { background: var(--income-bg); color: var(--income); }
.badge.expense { background: var(--expense-bg); color: var(--expense); }

.amount-income  { color: var(--income); font-weight: 700; }
.amount-expense { color: var(--expense); font-weight: 700; }

tfoot td {
  font-weight: 700;
  background: #fafbfc;
  border-top: 2px solid var(--border);
}

.empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Forms ---------- */

.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  max-width: 520px;
}

.field { margin-bottom: 16px; }

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

input, select {
  width: 100%;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 48px;
}

input:focus, select:focus {
  outline: 2px solid rgba(226, 87, 31, .35);
  border-color: var(--brand);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.field-error {
  color: var(--expense);
  font-size: 14px;
  margin-top: 6px;
}

/* ---------- Live calculation ---------- */

.calc-box {
  background: #fff7f3;
  border: 1px dashed var(--brand);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  margin-bottom: 16px;
}

.calc-box strong {
  font-size: 20px;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
}

.calc-note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 16px 0 28px;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Mobile ---------- */

@media (max-width: 640px) {
  .header-inner { padding-top: 10px; padding-bottom: 10px; }
  .header-right { width: 100%; }
  .main-nav { flex: 1 1 auto; justify-content: space-between; }
  .main-nav a { padding: 8px 10px; font-size: 14px; }

  h1 { font-size: 20px; }

  .row-2 { grid-template-columns: 1fr; }

  .actions .btn { width: 100%; }

  .filters a { flex: 1 1 auto; text-align: center; }

  .date-filter { flex-direction: column; align-items: stretch; }
  .date-filter .btn { width: 100%; }

  th, td { padding: 10px 12px; font-size: 14px; }

  input, select, .btn { min-height: 52px; }
  .btn-install { min-height: 44px; }
}

/* ---------- Login ---------- */

.login-wrap {
  min-height: calc(100vh - 40px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 32px;
  padding-bottom: 32px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 24px;
  text-align: center;
}

.login-card form { text-align: left; }
.login-card .flash { text-align: left; }

.login-logo img {
  display: block;
  width: 88px;
  height: 88px;
  margin: 0 auto;
  border-radius: 18px;
}

.login-title {
  font-size: 22px;
  margin: 14px 0 20px;
}

/* ---------- User menu ---------- */

.user-menu { position: relative; }

.user-menu > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
}

.user-menu > summary::-webkit-details-marker { display: none; }

.user-menu > summary:hover,
.user-menu[open] > summary {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.user-menu .caret { font-size: 11px; }

.user-menu-body {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 190px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
  padding: 6px;
  z-index: 60;
}

.user-menu-body a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.user-menu-body a:hover {
  background: var(--bg);
  text-decoration: none;
}

/* ---------- Small / status buttons ---------- */

.btn-small {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-danger { background: var(--expense); border-color: var(--expense); }
.btn-danger:hover { background: #a51f1f; border-color: #a51f1f; color: #fff; }

.btn-success { background: var(--income); border-color: var(--income); }
.btn-success:hover { background: #0f6a3b; border-color: #0f6a3b; color: #fff; }

/* ---------- Table actions ---------- */

.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin: 2px 6px 2px 0; }
.inline-form { display: inline; }

/* ---------- Mobile: hamburger button + slide-in sidebar ---------- */

.menu-btn,
.drawer-head,
.nav-overlay { display: none; }

@media (max-width: 640px) {
  .header-inner { position: relative; }

  .menu-btn {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 46px;
    height: 46px;
    margin-left: auto;
    padding: 0 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    z-index: 100;
  }

  .menu-btn span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform .2s ease, opacity .2s ease;
  }

  body.nav-open .menu-btn span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  body.nav-open .menu-btn span:nth-child(2) { opacity: 0; }
  body.nav-open .menu-btn span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  body.nav-open { overflow: hidden; }

  .nav-overlay {
    display: block;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(16, 24, 40, .45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
    z-index: 80;
  }

  body.nav-open .nav-overlay { opacity: 1; visibility: visible; }

  .header-right {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(84vw, 320px);
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 14px 14px 24px;
    flex: none;
    flex-wrap: nowrap;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 10px;
    background: var(--card);
    border-left: 1px solid var(--border);
    box-shadow: -10px 0 30px rgba(16, 24, 40, .2);
    overflow-y: auto;
    transform: translateX(105%);
    transition: transform .22s ease;
    z-index: 90;
  }

  body.nav-open .header-right { transform: translateX(0); }

  .drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
  }

  .drawer-title { font-size: 16px; font-weight: 700; }

  .drawer-close {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 10px;
    font-size: 24px;
    line-height: 1;
    color: var(--text);
    cursor: pointer;
  }

  .main-nav {
    flex: none;
    flex-direction: column;
    justify-content: flex-start;
    width: 100%;
    gap: 4px;
  }

  .main-nav a {
    padding: 13px 12px;
    font-size: 16px;
    border-radius: 10px;
  }

  .user-menu { width: 100%; }

  .user-menu > summary {
    width: 100%;
    justify-content: space-between;
    padding: 13px 12px;
    font-size: 16px;
  }

  .user-menu-body {
    position: static;
    min-width: 0;
    margin-top: 0;
    padding: 4px 0 0 8px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .user-menu-body a { padding: 12px; }

  .btn-install { width: 100%; margin-left: 0; min-height: 48px; }
}

/* ---------- Mobile: compact dashboard (swipeable summary cards) ---------- */

@media (max-width: 640px) {
  .cards {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin-left: -16px;
    margin-right: -16px;
    padding: 2px 16px 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .cards::-webkit-scrollbar { display: none; }

  .cards .card {
    flex: 0 0 auto;
    width: min(76vw, 300px);
    scroll-snap-align: start;
    padding: 14px;
  }

  .card h2 { margin: 0 0 6px; font-size: 12.5px; }

  .stat { padding: 7px 0; }
  .stat .label { font-size: 14px; }
  .stat .value { font-size: 15px; }

  .actions { gap: 10px; margin-top: 14px; }
  .actions .btn { min-height: 44px; padding: 10px 12px; font-size: 14px; }

  .section { margin-top: 18px; }
}
