
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #d9e2ec;
  --text: #12263a;
  --muted: #5c6b7a;
  --primary: #2563eb;
  --secondary: #0f766e;
  --danger: #dc2626;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }
code {
  background: #eef2ff;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 0.92em;
}

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

.sidebar {
  background: linear-gradient(180deg, #0f172a, #1e293b);
  color: white;
  padding: 28px 20px;
}

.brand {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 28px;
}

.nav-links {
  display: grid;
  gap: 12px;
}

.nav-links a {
  padding: 12px 14px;
  border-radius: 12px;
  color: rgba(255,255,255,0.82);
  transition: 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,0.1);
  color: white;
}

.main-content {
  padding: 28px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 2rem;
}

.page-header p {
  margin: 0;
  color: var(--muted);
}

.stats-grid,
.panel-grid,
.form-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 24px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid {
  grid-template-columns: 1.2fr 0.8fr;
}

.stat-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 20px;
}

.stat-label {
  display: block;
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 2rem;
}

.panel {
  padding: 22px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.card-link p { min-height: 64px; }

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

input[type="text"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: white;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
}

textarea { resize: vertical; }

small,
.form-note {
  color: var(--muted);
  display: block;
  margin-top: 8px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-light { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 8px 12px; font-size: 0.9rem; }

.table-wrapper {
  overflow: auto;
}

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

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

th {
  background: #f8fafc;
  font-size: 0.92rem;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
}

.pill {
  background: #dbeafe;
  color: #1d4ed8;
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: capitalize;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.alert {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
}

.alert-success {
  background: #ecfdf5;
  color: #166534;
  border: 1px solid #bbf7d0;
}

@media (max-width: 1080px) {
  .stats-grid,
  .panel-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    padding-bottom: 12px;
  }
}

.form-help {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: #666;
}

.alert-error {
  background: #fde8e8;
  color: #b42318;
  border: 1px solid #f5c2c7;
  padding: 12px 14px;
  border-radius: 8px;
  margin-top: 16px;
}

.summary-list {
  display: grid;
  gap: 12px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}

.actions-cell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-small {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  border: none;
}

.btn-danger:hover {
  opacity: 0.92;
}

.details-cell {
  background: #fafafa;
  padding: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.detail-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
}

.detail-card h3 {
  margin-top: 0;
  margin-bottom: 12px;
}

.message-preview pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f3f4f6;
  padding: 12px;
  border-radius: 8px;
  margin-top: 8px;
}

.panel-inner-header {
  margin: 20px 0 12px;
}

.detail-loading {
  padding: 16px 0;
  color: #666;
}

.pill-success {
  background: #dcfce7;
  color: #166534;
}

.pill-pending {
  background: #fef3c7;
  color: #92400e;
}

.actions-cell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-small {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  border: none;
}

.btn-danger:hover {
  opacity: 0.92;
}

.details-cell {
  background: #fafafa;
  padding: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.detail-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
}

.detail-card h3 {
  margin-top: 0;
  margin-bottom: 12px;
}

.message-preview pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f3f4f6;
  padding: 12px;
  border-radius: 8px;
  margin-top: 8px;
}

.panel-inner-header {
  margin: 20px 0 12px;
}

.detail-loading {
  padding: 16px 0;
  color: #666;
}

.pill-success {
  background: #dcfce7;
  color: #166534;
}

.pill-pending {
  background: #fef3c7;
  color: #92400e;
}

.preview-list {
  margin-top: 8px;
  display: grid;
  gap: 4px;
}

.alert-error {
  background: #fde8e8;
  color: #b42318;
  border: 1px solid #f5c2c7;
  padding: 12px 14px;
  border-radius: 8px;
  margin-top: 16px;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: 12px 14px;
  border-radius: 8px;
  margin-top: 16px;
}