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

:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --primary: #2d89ef;
  --accent: #7c4dff;
  --text: #1f2933;
  --muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(31, 41, 51, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--primary);
  text-decoration: none;
}

.page {
  min-height: 100vh;
}

.layout-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0f9af0, #2674ff);
  color: #fff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  display: grid;
  gap: 6px;
}

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

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.sidebar-link {
  padding: 12px 14px;
  border-radius: 12px;
  color: #f2f6ff;
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.main {
  display: flex;
  flex-direction: column;
}

.page-login .layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  min-height: 100vh;
  align-items: center;
  gap: 32px;
  padding: 40px clamp(16px, 4vw, 64px);
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
}

.shadow {
  box-shadow: var(--shadow);
}

.glass {
  background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,255,255,0.75));
  backdrop-filter: blur(6px);
}

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

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow: var(--shadow);
}

.brand-icon.small {
  width: 38px;
  height: 38px;
  font-size: 14px;
}

.brand-name {
  font-weight: 700;
  font-size: 20px;
}

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

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.field input {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field select {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 137, 239, 0.15);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: var(--shadow);
}

.btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn.success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #ffffff;
  box-shadow: var(--shadow);
}

.btn.warning {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #3b2f0f;
  box-shadow: var(--shadow);
}

.btn.primary:hover {
  transform: translateY(-1px);
}

.btn.full {
  width: 100%;
}

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

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
}

.alert.error {
  background: #fff0f0;
  color: #b00020;
  border: 1px solid #ffd4d4;
}

.alert.success {
  background: #ecfdf3;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: clamp(16px, 2vw, 32px);
}

.hero-title {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
}

.hero-text {
  color: var(--muted);
  font-size: 16px;
}

.topbar {
  height: 64px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

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

.brand-text {
  font-weight: 700;
}

.user-chip {
  text-align: right;
}

.user-name {
  font-weight: 700;
}

.user-role {
  color: var(--muted);
  font-size: 13px;
}

.content {
  padding: 24px clamp(12px, 5vw, 32px) 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.grid.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card-1 { background: linear-gradient(135deg, #2d89ef, #6dd5fa); color: #fff; }
.stat-card-2 { background: linear-gradient(135deg, #9c27b0, #e040fb); color: #fff; }
.stat-card-3 { background: linear-gradient(135deg, #00b09b, #96c93d); color: #fff; }
.stat-card-4 { background: linear-gradient(135deg, #ff8c42, #ff3d68); color: #fff; }

.label {
  color: inherit;
  font-size: 13px;
  letter-spacing: 0.2px;
  opacity: 0.9;
}

.value {
  font-size: 28px;
  font-weight: 700;
  margin: 4px 0;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.15);
  color: inherit;
  cursor: pointer;
}

.hint {
  color: inherit;
  font-size: 12px;
  opacity: 0.9;
}

.section-table {
  overflow: hidden;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.table-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  flex-wrap: wrap;
}

.table-controls select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.chart-wrapper {
  width: 100%;
  min-height: 220px;
}

.pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 0 4px;
  font-size: 14px;
}

.page-link {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
}

.section-title {
  font-weight: 700;
  font-size: 18px;
}

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

.search {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 220px;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.3px;
}

tr:hover td {
  background: #f2f6ff;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: #eef2ff;
  color: #30336b;
  font-size: 12px;
  margin: 2px;
}

.badge-red {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-yellow {
  background: #fef9c3;
  color: #b45309;
}

.badge-green {
  background: #dcfce7;
  color: #166534;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badges {
  min-width: 180px;
}

.badges .btn {
  padding: 8px 10px;
  font-size: 13px;
}

.ellipsis {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .layout-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    height: 100vh;
    width: 240px;
    transition: left 0.2s ease;
    z-index: 20;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .topbar {
    height: auto;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
  }

  .section-header {
    align-items: flex-start;
  }

  th:nth-child(6), td:nth-child(6) {
    max-width: 180px;
  }
}

.layout-shell.collapsed {
  grid-template-columns: 0px 1fr;
}

.layout-shell.collapsed .sidebar {
  width: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
}

.layout-shell.collapsed .main {
  grid-column: 1 / -1;
}

/* Extra mobile refinements */
@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  .content {
    padding: 16px 12px 28px;
    gap: 14px;
  }

  .card {
    padding: 16px;
  }

  .grid.stats {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
  }

  .value {
    font-size: 22px;
  }

  .section-title {
    font-size: 16px;
  }

  .table-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-controls select,
  .table-controls input {
    width: 100%;
  }

  th, td {
    padding: 10px 8px;
    font-size: 13px;
  }

  .table-wrapper {
    margin: 0 -8px;
    padding: 0 8px;
  }

  .chart-wrapper {
    min-height: 180px;
  }
}
