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

:root {
  --ink: #1B2430;
  --slate: #66707D;
  --slate-light: #97A1AC;
  --paper: #FFFFFF;
  --surface: #F3F5F7;
  --border: #E2E6EB;
  --steel: #2B5C86;
  --steel-dark: #1E4361;
  --steel-tint: #EAF1F7;
  --success: #1F8A5F;
  --success-tint: #E6F4EE;
  --warning: #B0741E;
  --warning-tint: #FBF1E1;
  --danger: #C13A2E;
  --danger-tint: #FBEAE8;
  --radius: 6px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--steel); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------------- App shell ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--paper);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .company { font-size: 15px; font-weight: 700; color: var(--ink); }
.sidebar-brand .product { font-size: 12px; color: var(--slate); margin-top: 2px; }

.nav-group { padding: 14px 10px; }
.nav-group-label {
  font-size: 11px; color: var(--slate-light); font-weight: 600;
  padding: 6px 12px 4px; letter-spacing: 0.02em;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin: 1px 0; border-radius: var(--radius);
  color: var(--ink); font-size: 13.5px; font-weight: 500;
  border-left: 2px solid transparent;
}
.nav-link:hover { background: var(--surface); text-decoration: none; }
.nav-link.active { background: var(--steel-tint); color: var(--steel-dark); border-left-color: var(--steel); }
.nav-link .icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }

.sidebar-footer { margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; justify-content: space-between; }
.user-chip .name { font-size: 13px; font-weight: 600; }
.user-chip .role { font-size: 11.5px; color: var(--slate); }
.logout-btn { background: none; border: none; color: var(--slate); cursor: pointer; font-size: 12px; padding: 4px 0; }
.logout-btn:hover { color: var(--danger); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--paper); border-bottom: 1px solid var(--border);
  padding: 16px 28px; display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { font-size: 18px; }
.topbar .subtitle { font-size: 12.5px; color: var(--slate); margin-top: 2px; }

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

/* ---------------- Cards / stat tiles ---------------- */
.card {
  background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-header h2 { font-size: 14.5px; }
.card-header .hint { font-size: 12px; color: var(--slate); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-tile { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-tile .value { font-family: var(--font-mono); font-size: 24px; font-weight: 600; color: var(--ink); }
.stat-tile .label { font-size: 12px; color: var(--slate); margin-top: 4px; }
.stat-tile.accent .value { color: var(--steel); }
.stat-tile.warn .value { color: var(--warning); }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--paper); color: var(--ink); font-weight: 500; font-size: 13px; cursor: pointer;
}
.btn:hover { background: var(--surface); }
.btn-primary { background: var(--steel); border-color: var(--steel); color: #fff; }
.btn-primary:hover { background: var(--steel-dark); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-danger { color: var(--danger); border-color: var(--danger-tint); }
.btn-danger:hover { background: var(--danger-tint); }

/* ---------------- Forms ---------------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--slate); margin-bottom: 5px; }
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--steel-tint); border-color: var(--steel); }
textarea { resize: vertical; min-height: 60px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.form-error { color: var(--danger); font-size: 12.5px; margin-top: 8px; display: none; }
.form-error.show { display: block; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 11.5px; color: var(--slate); font-weight: 600;
  padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:hover { background: var(--surface); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.muted { color: var(--slate); }
.empty-state { padding: 40px 20px; text-align: center; color: var(--slate); font-size: 13px; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 100px; font-size: 11.5px; font-weight: 600;
  background: var(--surface); color: var(--slate);
}
.badge-steel { background: var(--steel-tint); color: var(--steel-dark); }
.badge-success { background: var(--success-tint); color: var(--success); }
.badge-warning { background: var(--warning-tint); color: var(--warning); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }

/* ---------------- Modal ---------------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(20, 26, 33, 0.45);
  align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--paper); border-radius: 8px; width: 100%; max-width: 560px;
  padding: 22px 24px; box-shadow: 0 12px 32px rgba(20,26,33,0.18);
}
.modal.modal-lg { max-width: 780px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h3 { font-size: 15.5px; }
.modal-close { background: none; border: none; font-size: 18px; color: var(--slate); cursor: pointer; line-height: 1; }

/* ---------------- Login page ---------------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--surface);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--paper); border: 1px solid var(--border);
  border-radius: 8px; padding: 32px 30px;
}
.login-card .brand { font-size: 17px; font-weight: 700; margin-bottom: 2px; }
.login-card .tagline { font-size: 12.5px; color: var(--slate); margin-bottom: 22px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; }

/* ---------------- Utility ---------------- */
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mb-0 { margin-bottom: 0; }
.text-sm { font-size: 12.5px; }
.w-full { width: 100%; }

.section-title {
  font-size: 13px; font-weight: 600; color: var(--slate); text-transform: uppercase;
  letter-spacing: 0.03em; margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 0; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -232px; z-index: 40; transition: left 0.15s ease; box-shadow: 0 0 0 100vw rgba(0,0,0,0); }
  .sidebar.open { left: 0; box-shadow: 8px 0 24px rgba(0,0,0,0.15); }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
