:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  --bg-page: #0f1115;
  --bg-surface: #181b21;
  --bg-surface-elevated: #20242c;
  --bg-input: #121418;
  
  --border-subtle: #272c35;
  --border-strong: #383f4d;
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --brand-primary: #3b82f6;
  --brand-primary-hover: #2563eb;
  --brand-subtle: rgba(59, 130, 246, 0.12);
  
  --status-active-bg: rgba(16, 185, 129, 0.12);
  --status-active-text: #34d399;
  --status-active-border: rgba(16, 185, 129, 0.25);
  
  --status-warning-bg: rgba(245, 158, 11, 0.14);
  --status-warning-text: #fbbf24;
  --status-warning-border: rgba(245, 158, 11, 0.3);
  
  --status-danger-bg: rgba(239, 68, 68, 0.14);
  --status-danger-text: #f87171;
  --status-danger-border: rgba(239, 68, 68, 0.3);
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="light"] {
    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f1f5f9;
    --bg-input: #ffffff;
    --border-subtle: #e2e8f0;
    --border-strong: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --brand-primary: #2563eb;
    --brand-primary-hover: #1d4ed8;
    --brand-subtle: rgba(37, 99, 235, 0.08);
    --status-active-bg: #ecfdf5;
    --status-active-text: #059669;
    --status-active-border: #a7f3d0;
    --status-warning-bg: #fffbeb;
    --status-warning-text: #d97706;
    --status-warning-border: #fde68a;
    --status-danger-bg: #fef2f2;
    --status-danger-text: #dc2626;
    --status-danger-border: #fecaca;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  }
}

* {
  box-sizing: border-box;
}

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

.screen {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Authentication Screen */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}

.brand-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--brand-primary);
  background: var(--brand-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin: 0 0 24px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 16px;
}

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

.brand-pill {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--brand-primary);
  background: var(--brand-subtle);
  border: 1px solid var(--border-strong);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
}

.header-brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.header-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Toast Message */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  box-shadow: var(--shadow-md);
  max-width: 360px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.toast-success {
  border-color: var(--status-active-border);
  color: var(--status-active-text);
}

.toast.toast-error {
  border-color: var(--status-danger-border);
  color: var(--status-danger-text);
}

/* Dashboard Content */
.dashboard-main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 28px;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.metric-card:hover {
  border-color: var(--border-strong);
}

.metric-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.text-success { color: var(--status-active-text); }
.text-warning { color: var(--status-warning-text); }
.text-danger { color: var(--status-danger-text); }

/* Grid Structure */
.dashboard-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 960px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.sidebar-forms {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.panel-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-header h2 {
  font-size: 0.96rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

/* Forms & Fields */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

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

input, select, textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
}

textarea {
  resize: vertical;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.checkbox-field input {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.checkbox-field label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Buttons */
button {
  font-family: var(--font-sans);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  border: none;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: #ffffff;
}

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

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}

.btn-outline:hover {
  background-color: var(--bg-surface-elevated);
}

.btn-subtle {
  background-color: transparent;
  color: var(--text-muted);
}

.btn-subtle:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-elevated);
}

.btn-danger-subtle {
  background-color: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.btn-danger-subtle:hover {
  color: var(--status-danger-text);
  border-color: var(--status-danger-border);
}

.full-width {
  width: 100%;
}

.error-text {
  color: var(--status-danger-text);
  font-size: 0.82rem;
  min-height: 20px;
  margin-top: 10px;
}

/* Chips */
.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.product-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.remove-chip {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1;
}

.remove-chip:hover {
  color: var(--status-danger-text);
}

/* Orders List Toolbar */
.orders-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 14px;
}

.toolbar-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-title-wrap h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.count-pill {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-box input {
  min-width: 220px;
  padding: 7px 12px;
  font-size: 0.82rem;
}

.filter-tabs {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.filter-tab {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 4px;
}

.filter-tab.active {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-weight: 600;
}

/* Order Cards Grid */
.orders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.order-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.15s ease;
}

.order-card:hover {
  border-color: var(--border-strong);
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.customer-handle {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  word-break: break-all;
}

.product-tag {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--brand-primary);
  background: var(--brand-subtle);
  padding: 2px 7px;
  border-radius: 4px;
  margin-top: 4px;
  font-weight: 500;
}

.order-meta-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.meta-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.meta-icon {
  font-size: 0.85rem;
  line-height: 1;
}

.meta-val {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.order-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-surface-elevated);
  padding: 6px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
  border-left: 2px solid var(--border-strong);
}

.order-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  gap: 8px;
}

.status-badge {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.status-badge.status-aktif {
  background: var(--status-active-bg);
  color: var(--status-active-text);
  border: 1px solid var(--status-active-border);
}

.status-badge.status-segera_habis {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
  border: 1px solid var(--status-warning-border);
}

.status-badge.status-habis {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border: 1px solid var(--status-danger-border);
}

.status-badge.status-tanpa_durasi {
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-actions button {
  font-size: 0.76rem;
  padding: 5px 9px;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
}

.empty-state p {
  margin: 6px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}
