:root {
  --primary: #1e5631;
  --primary-dark: #163e24;
  --primary-light: #2d7a46;
  --primary-subtle: #edf5f0;
  
  --accent: #b8862b;
  --accent-dark: #9a6d1f;
  --accent-light: #d4a044;
  --accent-subtle: #fbf7ee;
  
  --sapphire: #2f5f8a;
  --sapphire-subtle: #eef4f9;
  --amber: #a5691f;
  --amber-subtle: #fdf5ea;
  --jade: #2c7a5a;
  --jade-subtle: #eef8f3;
  --danger: #a13b2e;
  --danger-subtle: #fcf0ee;
  
  --bg-page: #f6f4ee;
  --bg-card: #ffffff;
  --bg-subtle: #f0ede4;
  
  --text-main: #1c2a20;
  --text-muted: #5c6a60;
  --text-soft: #8a978f;
  
  --border-color: #dcd6c5;
  --border-subtle: #e8e4d8;
  
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  
  --shadow-sm: 0 1px 3px rgba(28, 42, 32, 0.05);
  --shadow-md: 0 4px 12px rgba(28, 42, 32, 0.08);
  --shadow-lg: 0 10px 28px rgba(28, 42, 32, 0.12);
  
  --header-height: 64px;
  --sidebar-width: 260px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* --- Layout Grid --- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  height: var(--header-height);
  background-color: var(--primary-dark);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  border-bottom: 2px solid var(--accent);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  background-color: var(--accent);
  color: var(--primary-dark);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.tamil-text {
  font-size: 14px;
  color: var(--accent-light);
  font-weight: normal;
  margin-left: 4px;
}

.brand-sub {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #a3c4ae;
}

.branch-pill {
  background-color: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: rgba(255,255,255,0.08);
  padding: 4px 12px 4px 6px;
  border-radius: 24px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background-color: var(--accent-light);
  color: var(--primary-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
}

.user-role {
  font-size: 11px;
  color: #a3c4ae;
}

.icon-btn {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease;
}

.icon-btn:hover {
  background-color: rgba(255,255,255,0.15);
}

.action-btn-sm {
  background-color: var(--accent);
  color: var(--primary-dark);
  border: none;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.15s ease;
}

.action-btn-sm:hover {
  background-color: var(--accent-light);
}

.body-layout {
  display: flex;
  flex: 1;
}

/* --- Sidebar Navigation --- */
.sidebar {
  width: var(--sidebar-width);
  background-color: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 0;
  min-height: calc(100vh - var(--header-height));
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-soft);
  padding: 14px 20px 6px;
}

.section-sapphire { color: var(--sapphire); }
.section-amber { color: var(--amber); }
.section-jade { color: var(--jade); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.nav-item i {
  font-size: 15px;
  width: 20px;
  text-align: center;
}

.nav-item:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.nav-item.active {
  background-color: var(--primary-subtle);
  color: var(--primary-dark);
  font-weight: 600;
  border-left-color: var(--primary);
}

.nav-item.accent-sapphire.active {
  background-color: var(--sapphire-subtle);
  color: var(--sapphire);
  border-left-color: var(--sapphire);
}

.nav-item.accent-amber.active {
  background-color: var(--amber-subtle);
  color: var(--amber);
  border-left-color: var(--amber);
}

.nav-item.accent-jade.active {
  background-color: var(--jade-subtle);
  color: var(--jade);
  border-left-color: var(--jade);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
}

.sync-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
  margin-bottom: 4px;
}

.version-tag {
  font-size: 11px;
  color: var(--text-soft);
}

/* --- Content Viewport --- */
.content-viewport {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
  max-width: 1400px;
}

/* --- Login Viewport --- */
.login-viewport {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #163e24 0%, #0d2415 100%);
  padding: 20px;
}

.login-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  border-top: 4px solid var(--accent);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  width: 52px;
  height: 52px;
  background-color: var(--primary);
  color: var(--accent);
  border-radius: var(--radius-md);
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dark);
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 18px;
}

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

.form-input, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background-color: #ffffff;
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 86, 49, 0.15);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s ease;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
}

.demo-credentials-box {
  margin-top: 24px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 12px;
}

.demo-title {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.demo-account-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.demo-chip {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}

.demo-chip:hover {
  border-color: var(--primary);
}

/* --- Common UI Components --- */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.view-title-group h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-dark);
}

.view-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.view-actions {
  display: flex;
  gap: 10px;
}

.btn-secondary {
  padding: 8px 16px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary:hover {
  background-color: var(--bg-subtle);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.stat-meta {
  font-size: 12px;
  color: var(--text-soft);
}

/* Card & Table Styles */
.card-panel {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.card-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.data-table tr:hover td {
  background-color: #faf9f5;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #e0f2fe; color: #0369a1; }

/* Filter Bars */
.filter-bar {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  background-color: #faf8f2;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 220px;
  position: relative;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
}

.search-box input {
  padding-left: 36px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 20px;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  background: var(--primary-dark);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 4px solid var(--accent);
  animation: slideIn 0.2s ease;
}

.toast.error {
  border-left-color: var(--danger);
  background: #7f1d1d;
}

.toast.success {
  border-left-color: #22c55e;
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* POS Layout Styles */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  height: calc(100vh - var(--header-height) - 48px);
}

.pos-catalog {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.pos-cart {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
}

.product-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.product-card:hover {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.prod-name { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.prod-sku { font-size: 11px; color: var(--text-soft); font-family: var(--font-mono); }
.prod-price { font-size: 15px; font-weight: 700; color: var(--primary); font-family: var(--font-mono); margin-top: 8px; }
