:root {
  --bg: #f4f1e8;
  --surface: #fffdf8;
  --ink: #1f2933;
  --muted: #637381;
  --line: #d8d0c2;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --warning: #b45309;
  --danger: #b42318;
  --shadow: 0 12px 32px rgba(31, 41, 51, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #efe7d9 0%, #f8f5ef 35%, #f4f1e8 100%);
  color: var(--ink);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

.offline-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.85rem 1rem;
  text-align: center;
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #f59e0b;
}

.navbar, .nav-brand, .nav-links, .page-header, .page-header-actions, .form-actions, .search-bar, .pagination, .checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.navbar {
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(216, 208, 194, 0.9);
  position: sticky;
  top: 0;
  z-index: 40;
}

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

.nav-logo, .auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: #d7f4ef;
  color: var(--primary-dark);
  font-size: 1.2rem;
}

.nav-links { flex-wrap: wrap; justify-content: flex-end; }

.main-content {
  width: min(1180px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

.messages { display: grid; gap: 0.75rem; margin-bottom: 1rem; }

.alert {
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--surface);
}

.alert--success { background: #ecfdf3; border-color: #abefc6; color: #05603a; }
.alert--warning { background: #fffaeb; border-color: #fedf89; color: #b54708; }
.alert--error { background: #fef3f2; border-color: #fecdca; color: #b42318; }

.page-header {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.page-header h2, .auth-title { margin: 0; }
.text-muted, .page-info, .form-hint, .draft-status { color: var(--muted); }

.card, .auth-card {
  background: rgba(255, 253, 248, 0.95);
  border: 1px solid rgba(216, 208, 194, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card { padding: 1.25rem; }
.card--full { grid-column: 1 / -1; }
.section-title { margin-top: 0; margin-bottom: 1rem; font-size: 1.05rem; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn--primary, .nav-link--primary { background: var(--primary); color: #fff; }
.btn--primary:hover, .nav-link--primary:hover { background: var(--primary-dark); }
.btn--warning { background: #f59e0b; color: #fff; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--outline, .btn--ghost, .nav-link, .nav-link--logout { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn--sm { padding: 0.5rem 0.75rem; }
.btn--lg { padding-inline: 1.5rem; }
.btn--full { width: 100%; }

.search-bar { margin-bottom: 1rem; flex-wrap: wrap; }
.search-input { min-width: min(100%, 420px); flex: 1 1 320px; }

.form-grid, .detail-grid { display: grid; gap: 1rem; }
.form-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.form-grid--4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.form-group { display: grid; gap: 0.35rem; }
.form-label { font-weight: 600; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  color: var(--ink);
}

.form-textarea { min-height: 96px; resize: vertical; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: 2px solid rgba(15, 118, 110, 0.2); border-color: var(--primary); }
.form-error { margin: 0; color: var(--danger); font-size: 0.92rem; }
.checkbox-group { flex-wrap: wrap; }
.checkbox-label { display: inline-flex; align-items: center; gap: 0.5rem; }

.tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  margin-bottom: 1rem;
}

.tab {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.88);
  border-radius: 999px;
  padding: 0.7rem 1rem;
  white-space: nowrap;
}

.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.table-wrapper {
  overflow-x: auto;
  background: rgba(255, 253, 248, 0.95);
  border: 1px solid rgba(216, 208, 194, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(216, 208, 194, 0.8);
  text-align: left;
  vertical-align: top;
}

.table tbody tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.badge--success { background: #d1fadf; color: #05603a; }
.badge--warning { background: #fef0c7; color: #b54708; }
.empty-state, .auth-container { display: grid; place-items: center; }
.empty-state { min-height: 220px; text-align: center; }
.detail-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.detail-list { display: grid; grid-template-columns: minmax(120px, 150px) 1fr; gap: 0.6rem 1rem; margin: 0; }
.detail-list dt { font-weight: 700; }
.detail-list dd { margin: 0; }
.auth-container { min-height: calc(100vh - 3rem); }
.auth-card { width: min(420px, 100%); padding: 2rem; }
.auth-header { text-align: center; margin-bottom: 1.5rem; }
.auth-logo { margin: 0 auto 0.75rem; }
.auth-subtitle { color: var(--muted); }
.auth-form { display: grid; gap: 1rem; }
.draft-panel { margin-bottom: 1rem; }
.draft-panel p { margin: 0.35rem 0 0; }

@media (max-width: 768px) {
  .navbar, .page-header, .page-header-actions, .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .main-content {
    width: min(100% - 1rem, 1180px);
    margin-top: 1rem;
  }

  .card, .auth-card { padding: 1rem; }
  .detail-list { grid-template-columns: 1fr; }
}
