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

:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1a1d23;
  --text-secondary: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

[x-cloak] { display: none !important; }
.app-layout { display: flex !important; min-height: 100vh; width: 100%; }
.app-layout[style*="display: none"] { display: none !important; }

/* Auth gate */
.auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
}
.auth-box {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 360px;
  width: 100%;
}
.auth-box h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.auth-box p { color: var(--text-secondary); margin-bottom: 1rem; font-size: 0.875rem; }
.auth-box input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}
.auth-box button { width: 100%; }

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar .logo {
  font-weight: 700;
  font-size: 1.125rem;
  padding: 0 1rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar a:hover { background: var(--bg); color: var(--text); }
.sidebar a.active { color: var(--primary); background: #eff6ff; }

/* Content */
.content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  min-width: 0;
}

/* Buttons */
button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}
button:hover, .btn:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
th { font-weight: 600; color: var(--text-secondary); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: #f9fafb; }

/* Badge */
.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-new { background: #dbeafe; color: var(--primary); }
.badge-success { background: #d1fae5; color: var(--success); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-source-ted { background: #ede9fe; color: #7c3aed; }
.badge-source-etenders { background: #dbeafe; color: var(--primary); }

/* Text helpers */
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

/* Forms */
input, select, textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  width: 100%;
}
label { display: block; font-size: 0.8125rem; font-weight: 500; margin-bottom: 0.25rem; }
.form-group { margin-bottom: 1rem; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { text-align: center; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 0.8125rem; color: var(--text-secondary); }

/* Filters bar */
.filters-bar { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: end; }
.filters-bar .form-group { margin-bottom: 0; flex: 1; min-width: 150px; }

/* Pagination */
.pagination { display: flex; gap: 0.5rem; justify-content: center; margin-top: 1rem; align-items: center; }
.pagination button { padding: 0.375rem 0.75rem; }

/* Notice detail */
.notice-header { margin-bottom: 1.5rem; }
.notice-header h1 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.notice-meta { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.875rem; color: var(--text-secondary); }
.notice-section { margin-bottom: 1.5rem; }
.notice-section h2 { font-size: 1rem; margin-bottom: 0.5rem; }

/* AI Analysis section */
.ai-analysis { border-left: 3px solid var(--primary); }
.ai-analysis h2 { color: var(--primary); }
.ai-flag-list { list-style: none; padding: 0; margin: 0.5rem 0; }
.ai-flag-list li { padding: 0.25rem 0; font-size: 0.875rem; display: flex; align-items: flex-start; gap: 0.5rem; }

/* Mobile */
@media (max-width: 768px) {
  body { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0;
  }
  .sidebar .logo { display: none; }
  .sidebar a { white-space: nowrap; padding: 0.75rem 1rem; }
  .content { padding: 1rem; }
  .filters-bar { flex-direction: column; }
  .notice-meta { flex-direction: column; gap: 0.25rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
