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

:root {
  --brand: #E8500A;
  --brand-dark: #C44208;
  --brand-light: #F06B2A;
  --brand-subtle: #FDF2EC;
  --brand-border: #F5C4A8;

  --bg: #F8F8F7;
  --bg2: #F0EFED;
  --surface: #FFFFFF;
  --surface2: #FAFAF9;
  --border: #E5E4E0;
  --border2: #D8D6D0;

  --text: #1C1B19;
  --text2: #5C5A55;
  --text3: #9B9890;

  --green: #16A34A;
  --green-bg: #F0FDF4;
  --green-border: #BBF7D0;
  --yellow: #CA8A04;
  --yellow-bg: #FEFCE8;
  --yellow-border: #FEF08A;
  --red: #DC2626;
  --red-bg: #FEF2F2;
  --red-border: #FECACA;
  --blue: #2563EB;
  --blue-bg: #EFF6FF;
  --blue-border: #BFDBFE;
  --purple: #7C3AED;
  --purple-bg: #F5F3FF;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 2px 8px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.06);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'IBM Plex Mono', 'Fira Code', monospace;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ── */
h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.015em; }
h3 { font-size: 1rem; font-weight: 600; line-height: 1.4; }
h4 { font-size: 0.875rem; font-weight: 600; }
p { color: var(--text2); }
small { font-size: 0.75rem; }

/* ── Form Elements ── */
button { cursor: pointer; border: none; font-family: var(--font); font-size: 13px; font-weight: 500; transition: all 0.15s var(--ease); }
input, select, textarea {
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(232,80,10,0.1);
}
input::placeholder, textarea::placeholder { color: var(--text3); }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239B9890' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text2); margin-bottom: 5px; letter-spacing: 0.01em; }
textarea { resize: vertical; min-height: 80px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  line-height: 1;
}

.btn-primary { background: var(--brand); color: white; box-shadow: 0 1px 3px rgba(232,80,10,0.3); }
.btn-primary:hover { background: var(--brand-dark); box-shadow: 0 2px 8px rgba(232,80,10,0.35); }
.btn-primary:active { background: var(--brand-dark); transform: translateY(1px); }

.btn-secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border2); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--bg); border-color: var(--border2); }

.btn-ghost { background: transparent; color: var(--text2); border: 1.5px solid transparent; }
.btn-ghost:hover { background: var(--bg2); color: var(--text); }

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #B91C1C; }

.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #15803D; }

.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 5px; }
.btn-lg { padding: 11px 22px; font-size: 14px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); width: 32px; height: 32px; }

/* ── Card ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface2); border-radius: 0 0 var(--radius) var(--radius); }

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th { padding: 10px 16px; text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text3); background: var(--surface2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--brand-subtle); }

/* ── Badge / Tag ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-green { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-red { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }
.badge-blue { background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue-border); }
.badge-purple { background: var(--purple-bg); color: var(--purple); border: 1px solid #DDD6FE; }
.badge-gray { background: var(--bg2); color: var(--text2); border: 1px solid var(--border2); }
.badge-brand { background: var(--brand-subtle); color: var(--brand); border: 1px solid var(--brand-border); }

/* ── Status Indicator ── */
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; }
.status-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot.online::before { background: var(--green); box-shadow: 0 0 0 2px rgba(22,163,74,0.2); }
.status-dot.offline::before { background: var(--text3); }
.status-dot.busy::before { background: var(--yellow); box-shadow: 0 0 0 2px rgba(202,138,4,0.2); }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s var(--ease);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.payments-tax-modal {
  width: min(820px, calc(100vw - 80px));
  max-width: 820px;
  min-width: min(680px, calc(100vw - 80px));
}
.modal-header { padding: 18px 22px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 15px; }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ── Form Group ── */
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Toggle / Checkbox Styling ── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 42px;
  height: 24px;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle input[type="checkbox"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  margin: 0;
  z-index: 2;
}
.toggle-slider {
  width: 42px;
  height: 24px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 999px;
  display: inline-block;
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.03);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  background: var(--surface);
  border-radius: 50%;
  border: 1px solid var(--border2);
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s ease, background 0.22s ease, border-color 0.22s ease;
}
.toggle input:checked + .toggle-slider {
  background: var(--brand);
  border-color: var(--brand);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: var(--surface);
  border-color: var(--brand);
}
.toggle-label {
  font-size: 12px;
  color: var(--text2);
  font-weight: 600;
  line-height: 1.3;
}

/* ── GST Settings Layout ── */
.gst-settings-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(380px, 1fr);
  gap: 20px;
  align-items: stretch;
}
.gst-settings-card,
.gst-preview-card {
  min-width: 0;
}
.gst-settings-card .card-body,
.gst-preview-card .card-body {
  min-width: 0;
}
.gst-settings-card .form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 12px;
}
.gst-settings-card .form-group {
  margin-bottom: 12px;
}
.gst-settings-card .divider {
  margin: 14px 0;
}
.gst-settings-card .btn-block {
  width: 100%;
}
.gst-settings-card .toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}
.gst-settings-card .toggle-label {
  display: inline-block;
  vertical-align: middle;
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}
.gst-settings-card .toggle {
  width: 42px;
  height: 24px;
}
.gst-settings-card .toggle-slider {
  width: 42px;
  height: 24px;
}
.gst-settings-card .toggle-slider::before {
  width: 18px;
  height: 18px;
}

.gst-preview-sample-title {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 14px;
}
.gst-preview-bill {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.gst-preview-bill-head {
  background: var(--surface2);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.gst-preview-restaurant {
  font-weight: 700;
  color: var(--text);
}
.gst-preview-gstin {
  font-size: 11.5px;
  color: var(--text3);
  font-family: var(--mono);
  margin-top: 4px;
}
.gst-preview-bill-body {
  padding: 12px 14px;
}
.gst-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text2);
  border-bottom: 1px dashed var(--border);
}
.gst-preview-row:last-of-type {
  border-bottom: none;
}
.gst-preview-row-label {
  color: var(--text2);
}
.gst-preview-row-value {
  font-family: var(--mono);
  color: var(--text);
}
.gst-preview-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 0;
  font-size: 15px;
  font-weight: 700;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.gst-preview-total-label {
  color: var(--text);
}
.gst-preview-total-value {
  font-family: var(--mono);
  color: var(--brand);
}

@media (max-width: 900px) {
  .gst-settings-layout {
    grid-template-columns: 1fr;
  }
  .gst-settings-card .form-row {
    grid-template-columns: 1fr;
  }
}

/* ── Toast ── */
.toast-container { position: fixed; right: 18px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 9999; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast {
  background: var(--text);
  color: white;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 500;
  min-width: min(320px, calc(100vw - 36px));
  max-width: min(420px, calc(100vw - 36px));
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s var(--ease);
  display: flex; align-items: center; gap: 9px;
  pointer-events: auto;
  border-left: 4px solid var(--brand);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast::before { display: none; }
.toast-icon { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: white; }
.toast-icon svg { width: 18px; height: 18px; stroke-width: 2; }
.toast-text { min-width: 0; overflow-wrap: anywhere; }
.toast-close { width: 28px; height: 28px; min-width: 28px; border-radius: 50%; background: rgba(255,255,255,0.12); color: white; border: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; margin-left: auto; transition: background 0.2s ease; }
.toast-close svg { width: 16px; height: 16px; stroke-width: 2; }
.toast-close:hover { background: rgba(255,255,255,0.2); }
.toast.success, .toast-success { background: #15803D; border-left-color: #86EFAC; }
.toast.error, .toast-error { background: #B91C1C; border-left-color: #FCA5A5; }
.toast.info, .toast-info { background: #1D4ED8; border-left-color: #BFDBFE; }

/* ── Payments UI ── */
.payments-filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}
.payments-filter-field { margin-bottom: 0; }
.payments-filter-field label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text3); margin-bottom: 7px; }
.payments-filter-field select,
.payments-filter-field input {
  width: 100%;
}
.payments-filter-actions { display: flex; gap: 8px; align-items: end; white-space: nowrap; }
.payments-table-wrap { overflow-x: auto; }
.payments-data-table { min-width: 980px; width: 100%; }
.payments-data-table th,
.payments-data-table td { white-space: nowrap; }
.payments-data-table td:nth-child(1),
.payments-data-table td:nth-child(2),
.payments-data-table td:nth-child(12) { min-width: 90px; }
.payments-tax-modal-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin: 4px 0 16px;
}
.payments-tax-modal-year {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.payments-tax-modal .modal-body {
  padding: 20px 24px 22px;
}
.payments-tax-modal .modal-header {
  padding: 16px 22px;
}
.payments-tax-modal .modal-header h3 {
  font-size: 16px;
  margin: 0;
}
.payments-tax-stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.payments-tax-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text3);
  text-transform: uppercase;
}
.payments-tax-value {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.payments-tax-total {
  color: var(--brand);
}
.payments-tax-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 8px;
}

/* ── Empty State ── */
.empty-state { padding: 48px 24px; text-align: center; }
.empty-state .es-icon { width: 48px; height: 48px; background: var(--bg2); border-radius: var(--radius); margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; }
.empty-state h4 { font-size: 14px; margin-bottom: 4px; }
.empty-state p { font-size: 13px; color: var(--text3); }

/* ── Spinner ── */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.7s linear infinite; }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── Code / Mono ── */
code { font-family: var(--mono); font-size: 12.5px; background: var(--bg2); padding: 2px 6px; border-radius: 4px; color: var(--text); }

/* ── SVG Icons ── */
.icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon svg { stroke-width: 1.75; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes toastIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ── Utilities ── */
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text3); }
.text-brand { color: var(--brand); }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 88vh; }
  .modal-footer { position: sticky; bottom: 0; }
  .toast-container { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); align-items: stretch; }
  .toast { min-width: auto; max-width: none; width: 100%; }
  .form-row { grid-template-columns: 1fr; }
}
