@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700;9..144,800&family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  /* Core brand — deep emerald + warm gold, tuned for a richer, more futuristic contrast */
  --emerald-950: #061f17;
  --emerald-900: #0b2e22;
  --emerald-850: #0e3a2b;
  --emerald-800: #12503a;
  --emerald-700: #167149;
  --emerald-600: #189a5c;
  --emerald-500: #1cbd6e;
  --emerald-100: #e3f2e9;
  --emerald-50: #f2f8f4;

  --gold-700: #9c7a12;
  --gold-600: #b8901c;
  --gold-500: #d4af37;
  --gold-400: #e6c65c;
  --gold-300: #f0d98a;
  --gold-100: #faf1d9;

  /* Futuristic accent — cool cyan used sparingly for glow/energy against the warm gold */
  --accent-cyan: #2dd4c8;
  --accent-violet: #7c6fe0;

  --paper: #f7f5ef;
  --ink: #16211b;
  --ink-soft: #57655d;
  --line: #e5e1d4;
  --white: #ffffff;
  --danger: #c0392b;
  --danger-bg: #fdecec;
  --success: #178a54;
  --success-bg: #e6f7ee;
  --warn-bg: #fff6e0;

  --shadow-sm: 0 1px 3px rgba(6, 31, 23, 0.07);
  --shadow-md: 0 10px 28px rgba(6, 31, 23, 0.12);
  --shadow-lg: 0 26px 70px rgba(4, 20, 15, 0.32);
  --glow-emerald: 0 0 0 1px rgba(28, 189, 110, 0.12), 0 8px 24px rgba(28, 189, 110, 0.20);
  --glow-gold: 0 0 0 1px rgba(212, 175, 55, 0.18), 0 8px 22px rgba(212, 175, 55, 0.22);

  --radius: 16px;
  --radius-sm: 10px;
  --font-display: 'Fraunces', 'Georgia', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Space Grotesk', var(--font-body);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body { min-height: 100vh; }
h1, h2, h3, .display { font-family: var(--font-display); letter-spacing: -0.01em; }
button { font-family: inherit; }
a { color: inherit; }
::selection { background: var(--gold-300); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ============ Utility ============ */
.hidden { display: none !important; }
.arch-motif {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.06;
  background-repeat: no-repeat; background-position: center top; background-size: 420px;
}
.scroll-thin::-webkit-scrollbar { height: 6px; width: 6px; }
.scroll-thin::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }

/* Custom icon system */
.ic-svg { display: inline-block; vertical-align: -3px; flex-shrink: 0; }
button .ic-svg, a.btn .ic-svg { vertical-align: -3px; }
h3 .ic-svg { vertical-align: -3px; margin-right: 2px; color: var(--gold-600); }

/* ============ Loading splash ============ */
#splash {
  position: fixed; inset: 0; z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(60% 50% at 15% 10%, rgba(45, 212, 200, 0.16) 0%, transparent 60%),
    radial-gradient(70% 60% at 90% 90%, rgba(212, 175, 55, 0.14) 0%, transparent 60%),
    radial-gradient(120% 120% at 50% 0%, var(--emerald-800) 0%, var(--emerald-950) 60%, #030f0a 100%);
  color: var(--gold-300); gap: 18px;
}
#splash img { width: 92px; height: 92px; object-fit: contain; filter: drop-shadow(0 6px 24px rgba(0,0,0,.4)); animation: floatIn 1.1s ease; }
#splash .spin { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(232,201,106,.22); border-top-color: var(--accent-cyan); animation: spin 0.85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes floatIn { from { opacity: 0; transform: translateY(-14px) scale(.9); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ============ Login ============ */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(55% 45% at 12% 8%, rgba(45, 212, 200, 0.20) 0%, transparent 62%),
    radial-gradient(60% 55% at 100% 100%, rgba(212, 175, 55, 0.20) 0%, transparent 60%),
    radial-gradient(140% 100% at 50% -10%, var(--emerald-800) 0%, var(--emerald-950) 55%, #04120d 100%);
  position: relative; overflow: hidden;
}
#login-screen::before, #login-screen::after {
  content: ""; position: absolute; width: 640px; height: 640px; border-radius: 50%; filter: blur(4px);
  background: radial-gradient(circle, rgba(201,162,39,0.14) 0%, transparent 70%);
}
#login-screen::before { top: -220px; left: -200px; }
#login-screen::after { bottom: -260px; right: -180px; background: radial-gradient(circle, rgba(45,212,200,0.13) 0%, transparent 70%); }
.login-card {
  position: relative; z-index: 2; width: 100%; max-width: 400px;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(10px);
  border-radius: 24px; padding: 36px 30px 30px;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(45,212,200,0.06);
  border: 1px solid rgba(255,255,255,.5);
}
.login-logo-wrap { display: flex; flex-direction: column; align-items: center; margin-bottom: 6px; }
.login-logo-wrap img { width: 82px; height: 82px; object-fit: contain; margin-bottom: 10px; filter: drop-shadow(0 6px 16px rgba(11,46,34,.18)); }
.login-logo-wrap h1 { font-size: 22px; margin: 0; color: var(--emerald-900); text-align: center; line-height: 1.25; font-weight: 700; }
.login-logo-wrap p { margin: 4px 0 0; font-size: 12px; color: var(--gold-700); letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }

.role-tabs { display: flex; background: var(--emerald-50); border-radius: 13px; padding: 4px; margin: 22px 0 20px; gap: 4px; }
.role-tabs button {
  flex: 1; border: none; background: transparent; padding: 10px 8px; border-radius: 10px; font-weight: 600; font-size: 13.5px;
  color: var(--ink-soft); cursor: pointer; transition: all .18s; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.role-tabs button.active { background: linear-gradient(135deg, var(--emerald-700), var(--emerald-900)); color: var(--gold-300); box-shadow: var(--shadow-sm); }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 11px; font-size: 14.5px;
  background: var(--emerald-50); transition: border-color .15s, background .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--emerald-600); background: var(--white); box-shadow: 0 0 0 3px rgba(28,189,110,.13); }
.pw-wrap { position: relative; }
.pw-wrap button { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--ink-soft); padding: 6px; display: flex; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: none; border-radius: 11px;
  padding: 12px 18px; font-weight: 700; font-size: 14px; cursor: pointer; transition: transform .12s, box-shadow .15s, opacity .12s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--emerald-600), var(--emerald-900)); color: #fff; width: 100%; box-shadow: var(--glow-emerald); }
.btn-primary:hover { filter: brightness(1.08); box-shadow: var(--glow-emerald), var(--shadow-md); }
.btn-gold { background: linear-gradient(135deg, var(--gold-400), var(--gold-600)); color: var(--emerald-950); box-shadow: var(--glow-gold); }
.btn-gold:hover { filter: brightness(1.05); }
.btn-outline { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--emerald-600); color: var(--emerald-800); background: var(--emerald-50); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #fbdada; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }
.btn-icon { padding: 8px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }

.login-error { background: var(--danger-bg); color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; display: none; }
.login-footer { text-align: center; margin-top: 18px; font-size: 11.5px; color: #9aa39d; }

/* ============ App shell ============ */
#app-shell { display: none; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 50; color: var(--white);
  background: linear-gradient(120deg, var(--emerald-950) 0%, var(--emerald-900) 55%, #0a2b21 100%);
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  box-shadow: 0 2px 20px rgba(0,0,0,.22);
  border-bottom: 1px solid rgba(212,175,55,0.18);
}
.topbar img.brand-logo { width: 34px; height: 34px; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(0,0,0,.3)); }
.topbar .brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.topbar .brand-text b { font-family: var(--font-display); font-size: 15.5px; color: var(--gold-300); letter-spacing: .01em; }
.topbar .brand-text span { font-size: 10px; color: #9fb3a8; letter-spacing: .07em; }
.topbar .spacer { flex: 1; }
.topbar .user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.topbar .user-chip img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold-500); }
.topbar .user-chip .avatar-fallback {
  width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--emerald-600), var(--emerald-800)); color: var(--gold-300); display: flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 12px; border: 2px solid var(--gold-500);
}
.icon-btn { background: rgba(255,255,255,.08); border: none; color: #fff; width: 36px; height: 36px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.icon-btn:hover { background: rgba(255,255,255,.18); }
.modal-close-btn { background: #f2f1ea !important; color: #7a8078 !important; width: 30px; height: 30px; }
.modal-close-btn:hover { background: #e8e6db !important; color: var(--ink) !important; }

.app-body { display: flex; max-width: 1400px; margin: 0 auto; }
.sidebar {
  width: 236px; flex-shrink: 0; background: var(--white); border-right: 1px solid var(--line);
  min-height: calc(100vh - 60px); padding: 18px 12px; position: sticky; top: 60px; align-self: flex-start;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10.5px 13px; border-radius: 11px; color: var(--ink-soft);
  font-weight: 600; font-size: 13.5px; cursor: pointer; margin-bottom: 3px; transition: all .15s; border: none; background: none; width: 100%; text-align: left;
}
.nav-item .ic { display: flex; width: 20px; flex-shrink: 0; color: var(--ink-soft); transition: color .15s; }
.nav-item:hover { background: var(--emerald-50); color: var(--emerald-900); }
.nav-item:hover .ic { color: var(--emerald-700); }
.nav-item.active { background: linear-gradient(120deg, var(--emerald-800), var(--emerald-950)); color: var(--gold-300); box-shadow: var(--glow-emerald); }
.nav-item.active .ic { color: var(--gold-400); }
.nav-section-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color:#9aa39d; margin: 16px 10px 8px; font-weight: 700; }

.main-content { flex: 1; padding: 22px 26px 90px; min-width: 0; }
@media (max-width: 880px) {
  .sidebar { display: none; }
  .main-content { padding: 16px 14px 90px; }
}

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-header h2 { margin: 0 0 3px; font-size: 22px; color: var(--emerald-900); }
.page-header p { margin: 0; font-size: 13px; color: var(--ink-soft); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ Cards / grid ============ */
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--white); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); border: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; transition: transform .18s, box-shadow .18s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-ic { width: 48px; height: 48px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; }
.stat-ic.ic-emerald { background: linear-gradient(135deg, var(--emerald-500), var(--emerald-800)); box-shadow: var(--glow-emerald); }
.stat-ic.ic-gold { background: linear-gradient(135deg, var(--gold-400), var(--gold-700)); box-shadow: var(--glow-gold); }
.stat-ic.ic-blue { background: linear-gradient(135deg, var(--accent-violet), #4c3fb0); box-shadow: 0 0 0 1px rgba(124,111,224,.18), 0 8px 22px rgba(124,111,224,.24); }
.stat-ic.ic-mint { background: linear-gradient(135deg, var(--accent-cyan), #0e8f85); box-shadow: 0 0 0 1px rgba(45,212,200,.2), 0 8px 22px rgba(45,212,200,.24); }
.stat-card .stat-num { font-size: 25px; font-weight: 800; color: var(--emerald-900); font-family: var(--font-display); line-height: 1; }
.stat-card .stat-label { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.card { background: var(--white); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); border: 1px solid var(--line); margin-bottom: 18px; }
.card h3 { margin: 0 0 14px; font-size: 16px; color: var(--emerald-900); display: flex; align-items: center; gap: 8px; }

/* ============ Table ============ */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 480px; }
table.data-table th { background: var(--emerald-50); color: var(--emerald-900); text-align: left; padding: 11px 12px; font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; position: sticky; top: 0; }
table.data-table td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
table.data-table tbody tr:hover { background: var(--emerald-50); }
table.data-table input[type=number], table.data-table input[type=text] { width: 90px; padding: 7px 9px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 13px; }
table.data-table input:focus, table.data-table select:focus { outline: none; border-color: var(--emerald-600); box-shadow: 0 0 0 3px rgba(28,189,110,.12); }
table.data-table select { padding: 7px 9px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.pill-green { background: var(--success-bg); color: var(--success); }
.pill-red { background: var(--danger-bg); color: var(--danger); }
.pill-gold { background: var(--gold-100); color: var(--gold-700); }
.pill-gray { background: #eee; color: #777; }

.status-toggle { display: flex; gap: 4px; }
.status-toggle button { border: 1.5px solid var(--line); background: #fff; padding: 6px 10px; border-radius: 8px; font-size: 11.5px; font-weight: 700; cursor: pointer; color: #888; transition: all .12s; }
.status-toggle button.sel-H { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.status-toggle button.sel-I { background: #e6f0fd; border-color: #2563eb; color: #2563eb; }
.status-toggle button.sel-S { background: var(--warn-bg); border-color: var(--gold-600); color: var(--gold-700); }
.status-toggle button.sel-A { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }

/* ============ Forms / Modal ============ */
.overlay { position: fixed; inset: 0; background: rgba(6,26,20,.6); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(3px); }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: modalIn .18s ease; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16.5px; color: var(--emerald-900); }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.form-row input, .form-row select { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 14px; }
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--emerald-600); box-shadow: 0 0 0 3px rgba(28,189,110,.12); }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============ Filters ============ */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filter-bar .form-row { margin-bottom: 0; min-width: 150px; }

/* ============ Toast ============ */
#toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 999; display: flex; flex-direction: column; gap: 10px; max-width: 340px; }
.toast { padding: 13px 16px; border-radius: 12px; box-shadow: var(--shadow-md); font-size: 13.5px; font-weight: 600; animation: toastIn .2s ease; display: flex; gap: 10px; align-items: flex-start; }
.toast.ok { background: var(--success-bg); color: var(--success); border: 1px solid #b9e5cc; }
.toast.err { background: var(--danger-bg); color: var(--danger); border: 1px solid #f3c6c3; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

/* ============ Bottom nav (mobile) ============ */
.bottom-nav { display: none; }
@media (max-width: 880px) {
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--white); border-top: 1px solid var(--line);
    box-shadow: 0 -4px 20px rgba(0,0,0,.09); z-index: 60; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav button { flex: 1; background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; color: #9aa5a0; font-size: 10px; font-weight: 700; border-radius: 10px; }
  .bottom-nav button .ic { display: flex; }
  .bottom-nav button.active { color: var(--emerald-800); background: var(--emerald-50); }
  .bottom-nav button.more.active { color: var(--gold-700); }
}

/* ============ Ceklok page ============ */
.ceklok-hero { text-align: center; padding: 30px 20px; }
.ceklok-clock { font-family: var(--font-mono); font-size: 44px; color: var(--emerald-900); font-weight: 700; letter-spacing: .02em; }
.ceklok-date { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 22px; }
.ceklok-circle {
  width: 168px; height: 168px; border-radius: 50%; margin: 0 auto 22px; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 32% 28%, var(--emerald-600), var(--emerald-950));
  box-shadow: 0 16px 44px rgba(6,31,23,.4), 0 0 0 1px rgba(212,175,55,.25), 0 0 40px rgba(45,212,200,.12);
  border: 5px solid var(--gold-400); position: relative; color: var(--gold-300);
}
.ceklok-status-row { display: flex; justify-content: center; gap: 26px; margin-bottom: 22px; }
.ceklok-status-item { text-align: center; }
.ceklok-status-item .lbl { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.ceklok-status-item .val { font-size: 19px; font-weight: 800; color: var(--emerald-900); font-family: var(--font-mono); }
.geo-info { font-size: 12px; color: var(--ink-soft); margin-top: 10px; }

/* Profile avatar big */
.profile-hero { display: flex; flex-direction: column; align-items: center; padding: 8px 0 20px; }
.profile-avatar-wrap { position: relative; }
.profile-avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 4px solid var(--gold-400); box-shadow: var(--shadow-md); }
.profile-avatar-fallback { width: 96px; height: 96px; border-radius: 50%; background: linear-gradient(135deg, var(--emerald-700), var(--emerald-900)); color: var(--gold-300); display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 800; font-family: var(--font-display); border: 4px solid var(--gold-400); }
.profile-avatar-edit { position: absolute; bottom: 0; right: 0; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--gold-400), var(--gold-600)); border: 3px solid #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--emerald-950); box-shadow: var(--shadow-sm); }
.profile-hero h3 { margin: 12px 0 2px; }
.profile-hero p { margin: 0; color: var(--ink-soft); font-size: 13px; }

/* empty state */
.empty-state { text-align: center; padding: 46px 20px; color: var(--ink-soft); }
.empty-state .ic { display: flex; justify-content: center; margin-bottom: 12px; color: var(--line); }

.text-muted { color: var(--ink-soft); font-size: 12.5px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: none; }
