* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-light: #14b8a6;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --danger: #dc2626;
  --warning: #f59e0b;
  --success: #16a34a;
  --info: #2563eb;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* LOGIN */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
}
.login-card {
  background: white; border-radius: 12px; padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.login-card h1 { color: var(--primary); margin-bottom: 8px; }
.login-card p { color: var(--text-muted); margin-bottom: 24px; }

/* LAYOUT */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #0f172a;
  color: white;
  padding: 20px 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 0 20px 20px; border-bottom: 1px solid #1e293b; }
.sidebar .brand h2 { font-size: 18px; color: var(--primary-light); }
.sidebar .brand small { color: #94a3b8; font-size: 11px; }
.sidebar nav { padding: 12px 0; }
.sidebar nav a {
  display: block; padding: 10px 20px; color: #cbd5e1;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #1e293b; color: white; text-decoration: none; }
.sidebar nav a.active { background: #1e293b; color: white; border-left-color: var(--primary-light); }
.sidebar nav .group { padding: 16px 20px 6px; font-size: 11px; color: #64748b; text-transform: uppercase; }

.main { display: flex; flex-direction: column; }
.topbar {
  background: white; padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.topbar h1 { font-size: 18px; }
.topbar .user-info { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.content { padding: 24px; flex: 1; }

/* CARDS & GRID */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h2 { font-size: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
}

/* STAT CARDS */
.stat {
  background: var(--surface); padding: 20px; border-radius: 8px;
  border: 1px solid var(--border); border-left: 4px solid var(--primary);
}
.stat .label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.stat .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat.warn { border-left-color: var(--warning); }
.stat.danger { border-left-color: var(--danger); }
.stat.success { border-left-color: var(--success); }
.stat.info { border-left-color: var(--info); }

/* FORM */
.form-group { margin-bottom: 14px; }
label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 12px; color: var(--text-muted); text-transform: uppercase; }
input, select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-family: inherit; background: white;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.1); }
textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* BUTTON */
.btn {
  display: inline-block; padding: 9px 16px;
  background: var(--primary); color: white;
  border: none; border-radius: 6px; cursor: pointer;
  font-size: 14px; font-weight: 600;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-warn { background: var(--warning); color: white; }
.btn-success { background: var(--success); }
.btn-block { display: block; width: 100%; }

/* TABLE */
.table { width: 100%; border-collapse: collapse; background: white; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: #f1f5f9; font-weight: 600; font-size: 12px; text-transform: uppercase; color: var(--text-muted); }
.table tbody tr:hover { background: #f8fafc; }
.table .right { text-align: right; }
.table .center { text-align: center; }
.table-wrap { overflow-x: auto; }
.table tfoot td { background: #f1f5f9; font-weight: 700; }

/* BADGE */
.badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-default { background: #f1f5f9; color: var(--text-muted); }

/* MODAL */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal.show { display: flex; }
.modal-content { background: white; border-radius: 8px; padding: 24px; width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; }
.modal-content.lg { max-width: 900px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* MISC */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0 !important; }
.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.flex { display: flex; gap: 8px; align-items: center; }

/* POS */
.pos-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }
@media (max-width: 1024px) { .pos-grid { grid-template-columns: 1fr; } }
.pos-products { max-height: 70vh; overflow-y: auto; }
.pos-cart { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 16px; position: sticky; top: 16px; }
.pos-product { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; cursor: pointer; display: flex; justify-content: space-between; }
.pos-product:hover { background: #f1f5f9; }
.pos-product .nm { font-weight: 600; }
.pos-product .stk { font-size: 11px; color: var(--text-muted); }
.cart-item { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--border); align-items: center; }
.cart-item .qty { width: 60px; text-align: center; padding: 4px; }

@media print {
  .sidebar, .topbar, .toolbar, .btn, .no-print { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .content { padding: 0; }
  .card { border: none; padding: 0; }
}
