/* ============================================================
   CRS — Alliance Innovate  |  styles
   Plain CSS adaptation of the supplied shadcn/Tailwind design.
   ============================================================ */

:root {
  --radius: 12px;
  --background: #ffffff;
  --foreground: #1f2430;
  --card: #ffffff;
  --muted: #f4f5f7;
  --muted-foreground: #6b7280;
  --border: #e6e8ec;
  --input: #e6e8ec;

  /* Brand: blue -> indigo (from the supplied login gradient) */
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-foreground: #ffffff;
  --primary-soft: rgba(79, 70, 229, 0.10);

  --blue: #2563eb;
  --indigo: #4f46e5;
  --purple: #7c3aed;

  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, .08);
  --shadow-lg: 0 20px 45px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--foreground);
  background: var(--background);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Animations ---------------- */
@keyframes blob {
  0%,100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(30px,-50px) scale(1.1); }
  66% { transform: translate(-20px,20px) scale(0.9); }
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-18px); } }
@keyframes fadeInUp { from { opacity:0; transform: translateY(16px);} to { opacity:1; transform:none; } }
@keyframes scaleIn { from { opacity:0; transform: scale(.94);} to { opacity:1; transform: scale(1);} }
.animate-blob { animation: blob 8s infinite; }
.animate-float { animation: float 6s ease-in-out infinite; }
.fade-up { animation: fadeInUp .5s ease-out both; }
.delay-1 { animation-delay: .1s; } .delay-2 { animation-delay: .2s; }
.delay-3 { animation-delay: .3s; } .delay-4 { animation-delay: .4s; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrap {
  display: flex; min-height: 100vh; overflow: hidden; position: relative;
  background: linear-gradient(135deg, #eff6ff 0%, #eef2ff 50%, #faf5ff 100%);
}
.login-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.login-bg span {
  position: absolute; border-radius: 9999px; filter: blur(60px); opacity: .35;
}
.login-bg .b1 { top: 5rem; left: 5rem; width: 18rem; height: 18rem; background: #60a5fa; }
.login-bg .b2 { top: 10rem; right: 5rem; width: 24rem; height: 24rem; background: #c084fc; animation-delay: 2s; }
.login-bg .b3 { bottom: 5rem; left: 10rem; width: 20rem; height: 20rem; background: #818cf8; animation-delay: 4s; }

.login-hero {
  flex: 1; display: none; align-items: center; justify-content: center; position: relative;
  color: #fff; padding: 3rem; overflow: hidden;
  background: linear-gradient(135deg, var(--blue), var(--indigo) 55%, var(--purple));
}
.login-hero .grid-mask {
  position: absolute; inset: 0;
  background-image: linear-gradient(to right,#ffffff14 1px,transparent 1px),
                    linear-gradient(to bottom,#ffffff14 1px,transparent 1px);
  background-size: 4rem 4rem;
  -webkit-mask-image: radial-gradient(ellipse 60% 50% at 50% 50%, #000 70%, transparent 100%);
          mask-image: radial-gradient(ellipse 60% 50% at 50% 50%, #000 70%, transparent 100%);
}
.login-hero .hero-inner { position: relative; z-index: 2; max-width: 28rem; }
.login-hero h1 { font-size: 2.8rem; line-height: 1.05; margin: .5rem 0 1rem; font-weight: 800; }
.login-hero p { font-size: 1.05rem; color: #dbeafe; }
.login-hero .logo-badge {
  width: 76px; height: 76px; border-radius: 18px; display: grid; place-items: center;
  background: rgba(255,255,255,.12); backdrop-filter: blur(4px); margin-bottom: 1rem;
}
.login-hero ul { list-style: none; padding: 0; margin: 1.75rem 0 0; }
.login-hero li { display: flex; align-items: center; gap: .6rem; color: #eff6ff; margin: .55rem 0; }
.login-hero li i { width: 8px; height: 8px; border-radius: 50%; background: #93c5fd; }

.login-form-col {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem; position: relative; z-index: 3;
}
.login-card {
  width: 100%; max-width: 26rem; background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.4); border-radius: 18px; box-shadow: var(--shadow-lg);
  padding: 2rem; animation: scaleIn .45s ease-out both;
}
.login-lock {
  width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--blue), var(--indigo)); color: #fff; box-shadow: var(--shadow-md);
}
.login-card h2 {
  text-align: center; margin: 0 0 .25rem; font-size: 1.7rem; font-weight: 800;
  background: linear-gradient(90deg, var(--blue), var(--indigo));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-card .sub { text-align: center; color: var(--muted-foreground); margin-bottom: 1.25rem; }

@media (min-width: 1024px) {
  .login-hero { display: flex; }
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .85rem; }
.req { color: var(--danger); }
.hint { color: var(--muted-foreground); font-size: .75rem; margin-top: .25rem; }

.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 .75rem; border: 1px solid var(--input);
  border-radius: 10px; background: #fff; font-size: .9rem; color: var(--foreground);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 72px; padding: .6rem .75rem; resize: vertical; }
.input:focus, select.input:focus, textarea.input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.input[readonly] { background: var(--muted); color: var(--muted-foreground); }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); }
.input-icon .input { padding-left: 2.3rem; }
.input-icon .toggle { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; color: var(--muted-foreground); padding: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  height: 40px; padding: 0 1.1rem; border: 1px solid transparent; border-radius: 10px;
  font-weight: 600; font-size: .9rem; cursor: pointer; transition: all .15s;
  background: var(--primary); color: var(--primary-foreground); box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--primary-600); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn-block { width: 100%; }
.btn-grad { background: linear-gradient(90deg, var(--blue), var(--indigo)); border: 0; }
.btn-grad:hover { filter: brightness(1.06); }
.btn-outline { background: #fff; color: var(--foreground); border-color: var(--border); box-shadow: none; }
.btn-outline:hover { background: var(--muted); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { height: 32px; padding: 0 .7rem; font-size: .8rem; border-radius: 8px; }

.row-inline { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* ============================================================
   APP SHELL  (sidebar + topbar)
   ============================================================ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px; flex-shrink: 0; background: #fbfbfd; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 8px; margin-bottom: 12px; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--blue), var(--indigo)); color: #fff; box-shadow: var(--shadow-sm);
}
.brand .b-name { font-weight: 700; font-size: .95rem; line-height: 1.1; }
.brand .b-sub { font-size: .72rem; color: var(--muted-foreground); }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav .heading {
  padding: 14px 10px 4px; font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: #9aa1ad;
}
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  color: var(--muted-foreground); font-weight: 500; font-size: .88rem; transition: all .15s;
}
.nav a:hover { background: #eef0f3; color: var(--foreground); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-bottom { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; border-bottom: 1px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px; position: sticky; top: 0; z-index: 5;
}
.topbar .title { font-weight: 600; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: .78rem; border: 1px solid rgba(79,70,229,.25);
}
.content { padding: 24px; max-width: 1280px; width: 100%; }

.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 1.6rem; margin: 0 0 2px; font-weight: 800; }
.page-head p { color: var(--muted-foreground); margin: 0; }

/* ============================================================
   CARDS / STATS / TABLE
   ============================================================ */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 20px; margin-bottom: 20px;
}
.card h3 { margin: 0 0 2px; font-size: 1.05rem; }
.card .card-sub { color: var(--muted-foreground); font-size: .85rem; margin-bottom: 14px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); display: flex; justify-content: space-between; align-items: flex-start;
}
.stat .label { color: var(--muted-foreground); font-size: .8rem; }
.stat .value { font-size: 1.5rem; font-weight: 800; margin-top: 4px; }
.stat .value.pos { color: var(--success); } .stat .value.neg { color: var(--danger); }
.stat .ic { width: 44px; height: 44px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th { color: var(--muted-foreground); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; }
table.data tr:hover td { background: #fafafe; }
table.data td.num, table.data th.num { text-align: right; }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--border); }

.badge {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 9999px;
  font-size: .72rem; font-weight: 600;
}
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.indigo { background: var(--primary-soft); color: var(--primary); }

.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: .88rem; font-weight: 500; }
.alert-success { background: var(--success-soft); color: #166534; }
.alert-error { background: var(--danger-soft); color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* Period segmented control */
.segmented { display: inline-flex; background: var(--muted); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg-btn {
  border: 0; background: transparent; cursor: pointer; padding: 6px 12px; border-radius: 8px;
  font-size: .82rem; font-weight: 600; color: var(--muted-foreground); transition: all .15s;
}
.seg-btn:hover { color: var(--foreground); }
.seg-btn.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }

.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.bar-row .bar-label { width: 90px; font-size: .82rem; }
.bar-track { flex: 1; height: 12px; background: var(--muted); border-radius: 9999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--indigo)); border-radius: 9999px; }
.bar-val { width: 110px; text-align: right; font-size: .82rem; font-weight: 600; }

.muted { color: var(--muted-foreground); }
.text-pos { color: var(--success); } .text-neg { color: var(--danger); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }

/* Mobile */
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -280px; z-index: 50; transition: left .25s; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .menu-btn { display: inline-flex !important; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: none; }
  .scrim.show { display: block; }
}
.menu-btn { display: none; background: none; border: 0; cursor: pointer; color: var(--foreground); padding: 6px; }

/* Logo image */
.logo-img { width: 36px; height: 36px; border-radius: 10px; display: block; box-shadow: var(--shadow-sm); }
.brand .logo-img { width: 36px; height: 36px; }

/* Theme (day/night) toggle */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--card); color: var(--muted-foreground); cursor: pointer; transition: all .15s;
}
.theme-toggle:hover { color: var(--foreground); background: var(--muted); }
.theme-toggle .moon { display: none; }
.dark .theme-toggle .moon { display: inline-flex; }
.dark .theme-toggle .sun { display: none; }
.theme-toggle-fixed { position: fixed; top: 16px; right: 16px; z-index: 20; }

/* ============================================================
   DARK MODE  (day/night vision)
   ============================================================ */
.dark {
  --background: #0f1115;
  --foreground: #e6e8ec;
  --card: #171a21;
  --muted: #1e222b;
  --muted-foreground: #9aa1ad;
  --border: #272c36;
  --input: #2a2f3a;
  --primary: #6366f1;
  --primary-600: #4f46e5;
  --primary-foreground: #ffffff;
  --primary-soft: rgba(99,102,241,.18);
  --success: #22c55e; --success-soft: #07351f;
  --danger: #ef4444; --danger-soft: #3a1414;
  --warning: #f59e0b; --warning-soft: #3a2a08;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 14px rgba(0,0,0,.5);
  --shadow-lg: 0 20px 45px rgba(0,0,0,.6);
}
.dark body { background: var(--background); color: var(--foreground); }
.dark .sidebar { background: #13161c; }
.dark .topbar { background: var(--card); }
.dark .nav a:hover { background: #222732; }
.dark .input, .dark select.input, .dark textarea.input { background: var(--input); color: var(--foreground); }
.dark .btn-outline { background: transparent; color: var(--foreground); }
.dark .btn-outline:hover { background: var(--muted); }
.dark .seg-btn.active { background: #2a2f3a; color: #c7d2fe; }
.dark table.data tr:hover td { background: #1c212b; }
.dark .alert-success { background: var(--success-soft); color: #bbf7d0; }
.dark .alert-error { background: var(--danger-soft); color: #fecaca; }
.dark .alert-info { background: #15233f; color: #bfdbfe; }
/* Login page in dark */
.dark .login-wrap { background: linear-gradient(135deg, #0f1115 0%, #131722 55%, #1a1326 100%); }
.dark .login-card { background: rgba(23,26,33,.92); border-color: rgba(255,255,255,.08); }
.dark .stat .value.pos { color: #4ade80; }
.dark .stat .value.neg { color: #f87171; }
