/* CivicTab Admin — light, friendly, spacious. For non-technical users. */
:root {
  --bg: #fafaf7;
  --panel: #ffffff;
  --panel-2: #f5f3ee;
  --border: #e5e3dd;
  --border-hover: #c9c6bd;
  --ink: #1a1a1f;
  --ink-dim: #5a544a;
  --ink-faint: #888178;
  --accent: #b8941e;
  --accent-soft: #fdf6e3;
  --green: #4caf6d;
  --green-soft: #e8f5ec;
  --red: #d34141;
  --red-soft: #fbe8e8;
  --blue: #3b6ce0;
  --blue-soft: #eaf0fd;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--ink); font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif; font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

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

/* SIDEBAR */
.sidebar { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 22px 14px 14px; }
.brand { padding: 4px 12px 22px; font-family: 'Bricolage Grotesque', 'Syne', sans-serif; font-weight: 800; letter-spacing: -0.5px; }
.brand-c { font-size: 1.3rem; color: var(--ink); }
.brand-dot { color: var(--accent); }
.brand-admin { font-size: 0.68rem; color: var(--accent); letter-spacing: 1.6px; margin-left: 8px; vertical-align: middle; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 9px; color: var(--ink-dim); font-size: 0.96rem; cursor: pointer; transition: background 0.12s, color 0.12s; font-weight: 500; }
.nav-item:hover { background: var(--panel-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }
.nav-badge { margin-left: auto; background: var(--panel-2); color: var(--ink-dim); font-size: 0.74rem; padding: 2px 8px; border-radius: 11px; font-weight: 700; }
.nav-item.active .nav-badge { background: var(--accent); color: #fff; }
.nav-badge:empty { display: none; }

.sidebar-foot { padding-top: 14px; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: 11px; padding: 10px 8px; border-radius: 9px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.96rem; }
.user-email { font-size: 0.84rem; color: var(--ink); font-weight: 600; max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.66rem; color: var(--ink-faint); letter-spacing: 1px; text-transform: uppercase; font-weight: 700; }
.user-signout { background: transparent; border: 1.5px solid var(--border); color: var(--ink-dim); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; margin-left: auto; font-size: 1rem; }
.user-signout:hover { color: var(--red); border-color: var(--red); }

/* MAIN */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 22px 32px 18px; background: var(--bg); position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--border); }
.topbar-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-title { font-family: 'Bricolage Grotesque', 'Syne', sans-serif; font-size: 1.65rem; font-weight: 800; color: var(--ink); letter-spacing: -0.5px; }
.page-sub { color: var(--ink-faint); font-size: 0.92rem; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-link { color: var(--ink-dim); font-size: 0.9rem; padding: 8px 14px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 600; }
.topbar-link:hover { color: var(--accent); border-color: var(--accent); }

.page { flex: 1; padding: 28px 32px; overflow-y: auto; }

/* DASHBOARD WIDGETS */
.widgets { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin-bottom: 32px; }
.widget { background: var(--panel); border: 1.5px solid var(--border); border-radius: 14px; padding: 22px 24px; transition: all 0.15s; cursor: grab; }
.widget:hover { border-color: var(--border-hover); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,0.04); }
.widget.dragging { opacity: 0.4; }
.widget.drop-target { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.widget-label { color: var(--ink-faint); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 1.4px; font-weight: 800; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.widget-drag { color: var(--ink-faint); cursor: grab; font-size: 0.9rem; }
.widget-value { font-size: 2.4rem; font-weight: 800; line-height: 1.05; font-family: 'Bricolage Grotesque', 'Syne', sans-serif; color: var(--ink); letter-spacing: -1px; }
.widget-value.accent { color: var(--accent); }
.widget-value.green { color: var(--green); }
.widget-value.red { color: var(--red); }
.widget-value.blue { color: var(--blue); }
.widget-sub { color: var(--ink-dim); font-size: 0.88rem; margin-top: 6px; }

.customize-toggle { color: var(--ink-faint); cursor: pointer; font-size: 0.92rem; padding: 8px 0; user-select: none; }
.customize-toggle:hover { color: var(--ink-dim); }
.customize-panel { background: var(--panel); border: 1.5px solid var(--border); border-radius: 12px; padding: 18px 22px; margin-top: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.customize-panel label { display: flex; align-items: center; gap: 9px; padding: 6px 0; color: var(--ink-dim); font-size: 0.92rem; cursor: pointer; }
.customize-panel input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }

/* TABLES + TOOLBAR */
.table-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.search-input { background: var(--panel); border: 1.5px solid var(--border); color: var(--ink); padding: 12px 16px; border-radius: 9px; min-width: 320px; outline: none; transition: border-color 0.15s; font-size: 0.96rem; }
.search-input:focus { border-color: var(--accent); }
.filter-chip { background: var(--panel); border: 1.5px solid var(--border); color: var(--ink-dim); padding: 9px 16px; border-radius: 9px; cursor: pointer; font-size: 0.9rem; font-weight: 600; }
.filter-chip:hover { border-color: var(--border-hover); color: var(--ink); }
.filter-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.btn { background: var(--accent); color: #fff; border: none; padding: 12px 22px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 0.95rem; transition: all 0.15s; }
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(184,148,30,0.25); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ghost { background: var(--panel); border: 1.5px solid var(--border); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--panel); }
.btn-danger { background: var(--red); }
.btn-danger:hover { box-shadow: 0 4px 12px rgba(211,65,65,0.25); }

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; }
.data-table thead { background: var(--panel-2); }
.data-table th { text-align: left; padding: 14px 18px; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 1.2px; color: var(--ink-faint); font-weight: 800; border-bottom: 1.5px solid var(--border); }
.data-table td { padding: 16px 18px; border-bottom: 1px solid var(--border); font-size: 0.94rem; color: var(--ink); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.clickable { cursor: pointer; transition: background 0.1s; }
.data-table tr.clickable:hover { background: var(--accent-soft); }
.data-table .actions { white-space: nowrap; text-align: right; }
.data-table .actions button { background: transparent; border: 1.5px solid var(--border); color: var(--ink-dim); padding: 6px 12px; border-radius: 7px; font-size: 0.82rem; cursor: pointer; margin-left: 6px; font-weight: 600; transition: all 0.12s; }
.data-table .actions button:hover { color: var(--ink); border-color: var(--accent); }
.data-table .actions button.danger:hover { color: var(--red); border-color: var(--red); }

.tag { display: inline-block; font-size: 0.74rem; padding: 3px 9px; border-radius: 5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; }
.tag.pending { background: var(--accent-soft); color: var(--accent); }
.tag.approved { background: var(--green-soft); color: var(--green); }
.tag.rejected { background: var(--red-soft); color: var(--red); }
.tag.demo { background: var(--panel-2); color: var(--ink-faint); border: 1px solid var(--border); }

/* MODAL */
.modal { position: fixed; inset: 0; background: rgba(20,20,25,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 24px; backdrop-filter: blur(3px); }
.modal-card { background: var(--panel); border-radius: 16px; max-width: 680px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 32px 36px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,0.18); }
.modal-close { position: absolute; top: 16px; right: 18px; background: var(--panel-2); border: 1.5px solid var(--border); color: var(--ink-dim); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 1.2rem; line-height: 1; }
.modal-close:hover { color: var(--ink); border-color: var(--ink-dim); }
.modal-card h2 { font-family: 'Bricolage Grotesque', 'Syne', sans-serif; font-size: 1.5rem; font-weight: 800; margin-bottom: 22px; color: var(--ink); letter-spacing: -0.5px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 1.2px; color: var(--ink-faint); font-weight: 800; margin-bottom: 7px; }
.field input, .field select, .field textarea { width: 100%; background: var(--panel); border: 1.5px solid var(--border); color: var(--ink); padding: 12px 14px; border-radius: 9px; outline: none; transition: border-color 0.15s; font-size: 0.95rem; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 130px; resize: vertical; font-family: inherit; line-height: 1.55; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }

/* TOAST */
.toast { position: fixed; bottom: 26px; right: 26px; background: var(--panel); border: 1.5px solid var(--border); color: var(--ink); padding: 14px 20px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 3000; font-size: 0.94rem; font-weight: 600; max-width: 360px; }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

/* SIGN-IN OVERLAY */
.signin { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.signin-card { background: var(--panel); border: 1.5px solid var(--border); border-radius: 16px; padding: 36px 32px; max-width: 400px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,0.04); }
.signin-card .cf-pill { background: var(--green-soft); border: 1.5px solid var(--green); border-radius: 9px; padding: 10px 14px; margin-bottom: 22px; display: flex; align-items: center; gap: 8px; color: var(--green); font-size: 0.88rem; }
.signin-card h1 { font-family: 'Bricolage Grotesque', 'Syne', sans-serif; font-size: 1.7rem; font-weight: 800; margin-bottom: 8px; color: var(--ink); letter-spacing: -0.5px; }
.signin-card .signin-sub { color: var(--ink-dim); font-size: 0.94rem; margin-bottom: 26px; line-height: 1.55; }

/* EMPTY / LOADING */
.empty { text-align: center; padding: 80px 20px; color: var(--ink-faint); font-size: 1rem; background: var(--panel); border: 1.5px solid var(--border); border-radius: 12px; }
.loading { display: inline-block; width: 16px; height: 16px; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; margin-right: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* MOBILE */
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { display: none; position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 100; box-shadow: 4px 0 18px rgba(0,0,0,0.18); }
  .sidebar.open { display: flex; }
  .topbar, .page { padding-left: 20px; padding-right: 20px; }
  .search-input { min-width: 0; width: 100%; }
}
