/* KRIOLIS Multi-AI CRM System — premium green admin UI */

:root {
  --g: #0a6b3b; --g2: #0e7d46; --gd: #063f26; --gn: #052b1a; --gsoft: #1f5e2e;
  --mint: #eef5f0; --mint2: #e3efe8; --paper: #f3f8f5;
  --ink: #1c2b23; --ink2: #41544a; --muted: #7c8c83; --line: #e0ebe4;
  --shadow: 0 1px 3px rgba(6,63,38,.06);
  --shadow-lg: 0 14px 34px -18px rgba(6,63,38,.30);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1100px 600px at 90% -10%, var(--mint) 0%, var(--paper) 60%) fixed;
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---- Topbar (premium green) ---- */
.topbar {
  display: flex; align-items: center; gap: 1.25rem;
  padding: .6rem 1.4rem;
  background: linear-gradient(135deg, var(--gd), var(--gn));
  color: #eaf6ee;
  box-shadow: 0 12px 32px -20px rgba(0,0,0,.7);
  flex-shrink: 0; position: relative; z-index: 5;
}
.brand { display: inline-flex; align-items: baseline; gap: .55rem; text-decoration: none; color: #fff; flex-shrink: 0; }
.brand-mark {
  font-weight: 900; font-size: 1.4rem; letter-spacing: .02em; color: #fff;
  text-shadow: 0 1px 0 #0c8a4e, 0 2px 0 #075a33, 0 3px 6px rgba(0,0,0,.35);
  transform: rotate(0deg); display: inline-block;
}
.brand-text { font-weight: 500; font-size: .68rem; letter-spacing: .22em; text-transform: uppercase; color: #a9d6bd; }

.nav { display: flex; gap: .2rem; flex: 1; flex-wrap: wrap; margin-left: .4rem; }
.nav a {
  color: #cfe6d8; text-decoration: none; padding: .4rem .7rem; border-radius: 8px;
  font-size: .85rem; font-weight: 500; white-space: nowrap;
  transition: background .14s, color .14s;
}
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav a.nav-accent { background: rgba(174,243,205,.18); color: #fff; font-weight: 600; border: 1px solid rgba(174,243,205,.28); }
.nav a.nav-accent:hover { background: rgba(174,243,205,.32); }

.logout-form { display: flex; align-items: center; gap: .7rem; flex-shrink: 0; }
.user { font-size: .78rem; color: #bcd9c8; background: rgba(255,255,255,.08); padding: .3rem .6rem; border-radius: 8px; }
.topbar .logout-form button { background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.22); color: #eaf6ee; }
.topbar .logout-form button:hover { background: rgba(255,255,255,.20); filter: none; }

/* ---- Buttons ---- */
button {
  padding: .45rem 1rem; border-radius: 9px; border: 1px solid var(--g);
  background: linear-gradient(135deg, var(--g2), var(--g)); color: #fff; cursor: pointer;
  font-size: .9rem; font-family: inherit; font-weight: 600;
  transition: filter .14s, transform .14s, box-shadow .14s;
}
button:hover { filter: brightness(1.06); transform: translateY(-1px); }

/* ---- Content / footer ---- */
.content { flex: 1; max-width: 1200px; width: 100%; margin: 1.6rem auto; padding: 0 1.5rem; }
.footer { text-align: center; padding: 1.1rem; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line); margin-top: 2rem; }

/* ---- Typography ---- */
h1 { font-size: 1.7rem; margin-bottom: 1.1rem; color: var(--gd); letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .75rem; color: var(--gd); }
h3 { font-size: 1.05rem; margin: 1rem 0 .5rem; color: var(--ink2); }
p { margin-bottom: .75rem; }
a { color: var(--g2); }
code { font-family: "SF Mono", Consolas, "Liberation Mono", monospace; font-size: .88em; color: var(--gd); background: var(--mint); padding: .1em .4em; border-radius: 5px; }

/* ---- KPIs ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; margin-bottom: 1.6rem; }
.kpi-card {
  position: relative; background: #fff; padding: 1.15rem 1.2rem; border-radius: 14px;
  box-shadow: var(--shadow); text-align: center; border: 1px solid var(--line); overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.kpi-card::before { content: ""; position: absolute; left: 0; top: 0; width: 100%; height: 3px; background: linear-gradient(90deg, var(--g2), #7ce0aa); opacity: .85; }
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.kpi-value { font-size: 2.1rem; font-weight: 800; color: var(--g); line-height: 1.1; }
.kpi-label { font-size: .77rem; color: var(--muted); margin-top: .35rem; text-transform: uppercase; letter-spacing: .05em; }

/* ---- Module cards ---- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.module-card {
  position: relative; background: #fff; padding: 1.3rem; border-radius: 14px;
  box-shadow: var(--shadow); border: 1px solid var(--line); text-decoration: none; color: inherit;
  transition: transform .15s, box-shadow .15s, border-color .15s; display: block;
}
.module-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #bfe0cd; }
.module-card h2 { color: var(--g); margin: 0 0 .5rem; font-size: 1.08rem; }
.module-card p { font-size: .88rem; color: var(--ink2); margin: 0; }

/* ---- Tables ---- */
.events-table, .data-table { width: 100%; background: #fff; border-radius: 12px; border-collapse: collapse; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
.events-table th, .events-table td, .data-table th, .data-table td { padding: .6rem .9rem; text-align: left; border-bottom: 1px solid var(--mint2); font-size: .9rem; }
.events-table th, .data-table th { background: var(--mint); font-weight: 700; color: var(--gd); text-transform: uppercase; font-size: .74rem; letter-spacing: .04em; }
.data-table a { color: var(--g2); text-decoration: none; font-weight: 600; }
.data-table a:hover { text-decoration: underline; }

/* ---- Status chips ---- */
.chip { display: inline-block; padding: .2rem .65rem; border-radius: 20px; color: #fff; font-size: .76rem; font-weight: 600; letter-spacing: .02em; }

/* ---- Detail grid ---- */
.detail-grid dl { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; background: #fff; padding: 1.1rem 1.3rem; border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); margin-bottom: 1.5rem; }
.detail-grid dt { font-weight: 700; color: var(--ink2); font-size: .86rem; }
.detail-grid dd { font-size: .95rem; }

/* ---- Forms ---- */
.edit-form { display: flex; flex-direction: column; gap: .8rem; max-width: 600px; background: #fff; padding: 1.3rem 1.5rem; border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.edit-form label { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; color: var(--ink2); }
.edit-form input, .edit-form select, .edit-form textarea { padding: .55rem .65rem; border: 1.5px solid var(--line); border-radius: 9px; font-size: .95rem; font-family: inherit; transition: border-color .15s, box-shadow .15s; }
.edit-form input:focus, .edit-form select:focus, .edit-form textarea:focus { outline: none; border-color: var(--g2); box-shadow: 0 0 0 3px rgba(14,125,70,.14); }
.edit-form button { align-self: flex-start; }

.btn-primary { display: inline-block; background: linear-gradient(135deg, var(--g2), var(--g)); color: #fff; padding: .55rem 1.2rem; border-radius: 9px; text-decoration: none; font-size: .92rem; font-weight: 600; box-shadow: 0 10px 22px -12px rgba(10,107,59,.6); transition: filter .14s, transform .14s; }
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }

.inline-form { display: flex; align-items: center; gap: .5rem; margin: .25rem 0; }
.inline-form input[type="text"], .inline-form select { padding: .4rem; border: 1.5px solid var(--line); border-radius: 8px; }
.inline-form button { padding: .4rem .9rem; }

/* ---- Embedded app iframe ---- */
.embedded-wrap { background: #fff; border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; margin-top: .75rem; border: 1px solid var(--line); }
.embedded-bar { display: flex; align-items: center; justify-content: space-between; padding: .6rem 1rem; background: var(--mint); border-bottom: 1px solid var(--line); font-size: .88rem; }
.embedded-bar .embedded-info { color: var(--ink2); }
.embedded-bar .embedded-info code { background: #fff; padding: .1em .4em; border-radius: 4px; }
.embedded-bar a { color: var(--g2); text-decoration: none; font-weight: 600; }
.embedded-bar a:hover { text-decoration: underline; }
.embedded-frame { width: 100%; height: calc(100vh - 220px); min-height: 600px; border: 0; display: block; }

/* ---- Auth (legacy fallback; auth pages load auth.css which overrides) ---- */
.auth-card { max-width: 400px; margin: 4rem auto; padding: 2rem; background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); }
.error { background: #fdecec; color: #b02a2a; padding: .6rem .9rem; border-radius: 9px; margin-bottom: 1rem; border-left: 3px solid #c53030; }

/* ---- Misc ---- */
small { color: var(--muted); }
em { color: var(--muted); font-style: italic; }
details summary { cursor: pointer; padding: .4rem; font-weight: 600; color: var(--ink2); }
details[open] summary { margin-bottom: .75rem; }

/* ---- AI advisory banner (shared: "AI suggests, human approves") ---- */
.ai-advisory { display: flex; gap: .7rem; align-items: flex-start; margin: .5rem 0 1.25rem; padding: .75rem 1rem; border-radius: 11px; background: #eef7f1; border: 1px solid #cfe6d7; border-left: 4px solid var(--g2); color: #1c3a2a; font-size: .86rem; line-height: 1.5; }
.ai-advisory .ai-advisory-ic { font-size: 1.05rem; line-height: 1.35; flex-shrink: 0; }
.ai-advisory strong { color: var(--gd); }
/* soft green info-note (replaces legacy blue inline notes) */
.note-ai { background: #eef7f1; border: 1px solid #cfe6d7; color: #194d31; padding: .5rem .75rem; border-radius: 8px; font-size: .82rem; }

/* ---- Mobile (phones / narrow tablets) ---- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: .45rem .6rem; padding: .5rem .8rem; }
  .brand-mark { font-size: 1.2rem; }
  .brand-text { display: none; }
  .logout-form { margin-left: auto; gap: .5rem; }
  .user { display: none; }
  .nav { order: 5; flex-basis: 100%; margin-left: 0; flex-wrap: nowrap; overflow-x: auto; gap: .15rem; padding-bottom: .15rem; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: .35rem .6rem; font-size: .82rem; }
  .content { margin: 1.1rem auto; padding: 0 .9rem; }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.1rem; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; }
  .kpi-value { font-size: 1.7rem; }
  .card-grid { grid-template-columns: 1fr; }
  /* wide tables scroll horizontally instead of overflowing the screen */
  .data-table, .events-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .detail-grid dl { grid-template-columns: 1fr; gap: .1rem .5rem; padding: 1rem; }
  .detail-grid dt { margin-top: .5rem; }
  .detail-grid dt:first-child { margin-top: 0; }
  .edit-form { padding: 1.1rem; }
  .embedded-frame { height: calc(100vh - 180px); min-height: 420px; }
}
