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

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

:root {
  --sidebar-bg: #fff;
  --sidebar-border: #e5e7eb;
  --sidebar-text: #6b7280;
  --sidebar-text-active: #111827;
  --sidebar-active-bg: #f0fdf9;
  --sidebar-active-border: #00ad9f;
  --accent: #00ad9f;
  --accent-hover: #009688;
  --bg: #f9fafb;
  --card-bg: #fff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  font-family: 'Inter', -apple-system, sans-serif;
}

body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; min-height: 100vh; background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; flex-shrink: 0;
  position: fixed; top: 0; left: 0; bottom: 0;
}
.sidebar-logo {
  padding: 18px 20px; font-size: 17px; font-weight: 700; color: var(--text);
  border-bottom: 1px solid var(--sidebar-border); letter-spacing: -.3px;
  display: flex; align-items: center; gap: 6px;
}
.sidebar-logo span { color: var(--accent); }
.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 8px; padding: 8px 20px;
  color: var(--sidebar-text); text-decoration: none; font-size: 13.5px; font-weight: 500;
  transition: background .12s, color .12s; border-left: 2px solid transparent;
  margin: 1px 0;
}
.sidebar-nav a:hover { background: #f9fafb; color: var(--text); }
.sidebar-nav a.active {
  background: var(--sidebar-active-bg); color: var(--accent);
  border-left-color: var(--accent); font-weight: 600;
}
.sidebar-nav .nav-section {
  padding: 14px 20px 4px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: #9ca3af;
}
.sidebar-footer {
  padding: 14px 20px; border-top: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 8px; font-size: 13px;
}
.sidebar-footer span { color: var(--text-muted); flex: 1; }
.sidebar-footer a { color: var(--text-muted); text-decoration: none; }
.sidebar-footer a:hover { color: var(--accent); }

.main { margin-left: 220px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 52px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 14px; font-weight: 600; color: var(--text); }
.topbar-user { font-size: 13px; color: var(--text-muted); }

.content { padding: 28px; flex: 1; }

/* Cards */
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.card-title { font-size: 14px; font-weight: 600; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; color: var(--text); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer;
  border: none; text-decoration: none; transition: background .12s, box-shadow .12s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f9fafb; }
.btn-danger { background: #fff; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 9999px; font-size: 11px; font-weight: 600;
}
.badge-active   { background: #d1fae5; color: #065f46; }
.badge-expired  { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }
.badge-inactive { background: #fef3c7; color: #92400e; }
.badge-synced   { background: #d1fae5; color: #065f46; }
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-error    { background: #fee2e2; color: #991b1b; }
.badge-admin    { background: #ede9fe; color: #5b21b6; }
.badge-supplier { background: #dbeafe; color: #1e40af; }
.badge-user     { background: #f3f4f6; color: #374151; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 9px 14px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
  border-bottom: 1px solid var(--border); background: #f9fafb;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

/* Forms */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,173,159,.1);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.3);
  z-index: 100; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 10px; padding: 24px; width: 480px; max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.12);
}
.modal-title { font-size: 15px; font-weight: 600; margin-bottom: 18px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 36px; width: 400px; box-shadow: var(--shadow);
}
.auth-logo { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 24px; }
.auth-logo span { color: var(--accent); }
.auth-footer { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-muted); }
.auth-footer a { color: var(--accent); text-decoration: none; }

/* Alert */
.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

/* Pagination */
.pagination { display: flex; gap: 4px; margin-top: 16px; }
.pagination a, .pagination span {
  padding: 5px 10px; border-radius: 5px; font-size: 13px; text-decoration: none;
  border: 1px solid var(--border); color: var(--text);
}
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Toast */
#toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 999;
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; transition: opacity .25s; pointer-events: none;
}
#toast.show { opacity: 1; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
}
