:root {
  --bg: #eef4f1;
  --surface: #ffffff;
  --surface2: #f7faf8;
  --text: #10201b;
  --muted: #60726b;
  --line: #dce7e1;
  --green: #13775b;
  --green2: #0f513f;
  --green3: #e6f5ef;
  --blue: #2563eb;
  --orange: #f59e0b;
  --red: #dc2626;
  --shadow: 0 18px 45px rgba(15, 35, 28, .09);
  --shadow2: 0 8px 22px rgba(15, 35, 28, .07);
  --radius: 24px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(19,119,91,.16), transparent 34rem),
    radial-gradient(circle at top right, rgba(37,99,235,.08), transparent 30rem),
    linear-gradient(180deg, #fbfdfc 0%, var(--bg) 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
body.no-scroll { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  padding: 30px;
}
.boot-screen img { width: 86px; height: 86px; object-fit: cover; border-radius: 24px; box-shadow: var(--shadow); }
.boot-screen h1 { margin: 6px 0 0; font-size: clamp(28px, 4vw, 44px); letter-spacing: -.05em; }
.boot-screen p { margin: 0; color: var(--muted); }

.app-shell { min-height: 100vh; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  background: rgba(246, 250, 248, .88);
  border-bottom: 1px solid rgba(220, 231, 225, .85);
  backdrop-filter: blur(16px);
}
.brand {
  border: 0;
  color: white;
  background: linear-gradient(135deg, #0b1f1a, #145846 60%, #178b69);
  border-radius: 22px;
  min-width: 250px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  box-shadow: var(--shadow2);
}
.brand img { width: 52px; height: 52px; border-radius: 17px; object-fit: cover; background: rgba(255,255,255,.08); }
.brand strong { display: block; font-size: 16px; line-height: 1.1; }
.brand em { display: block; margin-top: 4px; color: rgba(255,255,255,.72); font-size: 12px; font-style: normal; font-weight: 800; }

.main-nav {
  display: flex;
  gap: 8px;
  justify-content: center;
  overflow-x: auto;
  padding: 4px;
}
.main-nav button,
.tabs button,
.btn {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.88);
  color: #24443a;
  min-height: 42px;
  padding: 10px 14px;
  font-weight: 900;
  white-space: nowrap;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
}
.main-nav button:hover,
.tabs button:hover,
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow2); }
.main-nav button.active,
.tabs button.active {
  color: white;
  background: linear-gradient(135deg, var(--green), var(--green2));
  border-color: transparent;
  box-shadow: 0 12px 25px rgba(19, 119, 91, .18);
}
.header-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.sync { color: #9a3412; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 999px; padding: 10px 12px; font-weight: 900; font-size: 13px; }

.content {
  width: min(1500px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 46px;
}
.page-title {
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(220, 231, 225, .72);
  border-radius: 28px;
  padding: 22px 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow2);
}
.page-title p,
.label {
  margin: 0 0 7px;
  color: var(--green2);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.page-title h1 { margin: 0; font-size: clamp(30px, 4vw, 48px); line-height: .95; letter-spacing: -.06em; }
.page-title span { display: block; margin-top: 8px; color: var(--muted); line-height: 1.4; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 18px;
  align-items: stretch;
  color: white;
  background: linear-gradient(135deg, #0b1f1a, #163e35 50%, #13805f);
  border-radius: 34px;
  padding: clamp(24px, 4vw, 44px);
  box-shadow: 0 26px 70px rgba(16, 32, 27, .18);
  overflow: hidden;
}
.hero h2 { margin: 0 0 12px; font-size: clamp(36px, 5.4vw, 66px); line-height: .96; letter-spacing: -.07em; max-width: 900px; }
.hero p:not(.label) { margin: 0; color: rgba(255,255,255,.76); line-height: 1.55; max-width: 800px; }
.hero .label { color: rgba(255,255,255,.72); }
.quick-stats { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.quick-stats div { border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.10); border-radius: 22px; padding: 18px; }
.quick-stats strong { display: block; font-size: 34px; line-height: 1; }
.quick-stats span { display: block; margin-top: 7px; color: rgba(255,255,255,.72); font-weight: 800; }
.home-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; margin-top: 18px; }
.home-card {
  min-height: 240px;
  border: 1px solid rgba(220, 231, 225, .95);
  border-radius: 30px;
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow);
  padding: 26px;
  text-align: left;
  display: grid;
  align-content: space-between;
}
.home-card span { width: 62px; height: 62px; display: grid; place-items: center; border-radius: 22px; background: var(--green3); font-size: 34px; }
.home-card strong { display: block; margin-top: 28px; font-size: 28px; letter-spacing: -.04em; }
.home-card em { display: block; margin-top: 8px; color: var(--muted); font-style: normal; line-height: 1.48; }
.home-card:hover { transform: translateY(-4px); box-shadow: 0 28px 70px rgba(16,32,27,.14); }

.tabs { display: flex; flex-wrap: wrap; gap: 9px; margin: 0 0 16px; }
.toolbar { display: grid; grid-template-columns: minmax(0,1fr) 220px; gap: 12px; margin-bottom: 16px; }
.toolbar input,
.toolbar select,
.form-grid input,
.form-grid select,
.form-grid textarea,
.prompt-panel textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  color: var(--text);
  padding: 13px 14px;
  outline: none;
}
.toolbar input:focus,
.toolbar select:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.prompt-panel textarea:focus { border-color: rgba(19,119,91,.45); box-shadow: 0 0 0 4px rgba(19,119,91,.09); }

.panel,
.prompt-panel,
.error-panel {
  border: 1px solid rgba(220, 231, 225, .95);
  border-radius: 28px;
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow);
  padding: 18px;
}
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 14px; }
.section-head.block { display: block; }
.section-head h2 { margin: 0; font-size: clamp(23px, 2.4vw, 32px); letter-spacing: -.045em; }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.card-list { display: grid; gap: 12px; }
.card-list.compact { gap: 10px; }

.client-card,
.task-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: white;
  box-shadow: 0 8px 22px rgba(15,35,28,.055);
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 14px;
  align-items: center;
}
.client-card.paid { background: linear-gradient(0deg, #f0fdf4, white 72%); border-color: #bbf7d0; }
.client-card.sent { background: linear-gradient(0deg, #fffbeb, white 72%); border-color: #fde68a; }
.title-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.title-row h3,
.task-card h3 { margin: 0 0 6px; font-size: 18px; letter-spacing: -.025em; }
.title-row span { background: #eef4f1; border-radius: 999px; padding: 5px 9px; color: var(--muted); font-weight: 900; font-size: 12px; }
.client-info p,
.task-card p { margin: 0 0 9px; color: #435b53; line-height: 1.4; }
.meta { display: flex; flex-wrap: wrap; gap: 7px; color: var(--muted); font-size: 13px; }
.meta span { display: inline-flex; gap: 4px; border: 1px solid #e6eee9; background: var(--surface2); border-radius: 999px; padding: 6px 9px; }
details { margin-top: 10px; }
details summary { cursor: pointer; color: var(--green2); font-weight: 900; }
details pre { white-space: pre-wrap; margin: 10px 0 0; max-height: 240px; overflow: auto; border: 1px solid #e6eee9; background: var(--surface2); border-radius: 16px; padding: 12px; color: #435b53; line-height: 1.45; }
.actions,
.button-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.primary { color: white; background: linear-gradient(135deg, var(--green), var(--green2)); border-color: transparent; }
.btn.ghost { background: white; color: #24443a; }
.btn.success { color: #166534; background: #dcfce7; border-color: #bbf7d0; }
.btn.danger { color: white; background: var(--red); border-color: transparent; }
.btn.professor { color: white; background: linear-gradient(135deg, #111827, #7c3aed); border-color: transparent; }

.work-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); gap: 16px; align-items: start; }
.prompt-panel { position: sticky; top: 96px; }
.prompt-panel textarea { min-height: 420px; resize: vertical; line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.button-row { margin-top: 12px; }
.empty { padding: 18px; color: var(--muted); border: 1px dashed var(--line); background: var(--surface2); border-radius: 20px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 20px; background: white; }
table { width: 100%; min-width: 1040px; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: #435b53; background: var(--surface2); font-size: 13px; }
.paid-row td { background: #f0fdf4; }
.sent-row td { background: #fffbeb; }
.stats-row { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { border: 1px solid var(--line); border-radius: 20px; background: white; padding: 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow2); }
.stat-card > span { font-size: 28px; }
.stat-card strong { display: block; font-size: 21px; line-height: 1.1; }
.stat-card em { display: block; color: var(--muted); font-size: 13px; font-style: normal; margin-top: 4px; }
.simple-list { display: grid; gap: 10px; }
.simple-list > div { border: 1px solid var(--line); border-radius: 18px; background: white; padding: 14px; }
.simple-list strong { display: block; }
.simple-list span { display: block; margin-top: 4px; color: var(--muted); }

.error-panel { max-width: 780px; margin: 40px auto; }
.error-panel h2 { margin: 0 0 8px; }
.error-panel p { color: var(--muted); line-height: 1.5; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 32, 27, .48);
  backdrop-filter: blur(10px);
}
.modal-card { width: min(720px, 100%); max-height: 92vh; overflow: auto; background: white; border-radius: 28px; box-shadow: 0 30px 90px rgba(16,32,27,.3); padding: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; letter-spacing: -.04em; }
.x { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 14px; background: white; font-size: 24px; font-weight: 900; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.form-grid.single { grid-template-columns: 1fr; }
.form-grid label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 900; }
.form-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-note { color: var(--muted); line-height: 1.45; margin: 0; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 200;
  max-width: min(460px, calc(100vw - 44px));
  background: #10201b;
  color: white;
  border-radius: 18px;
  padding: 14px 18px;
  box-shadow: 0 20px 55px rgba(16,32,27,.22);
  font-weight: 900;
}
.toast.error { background: #991b1b; }

@media (max-width: 1050px) {
  .app-header { grid-template-columns: 1fr; align-items: stretch; }
  .brand { width: 100%; min-width: 0; }
  .main-nav { justify-content: flex-start; }
  .header-actions { justify-content: flex-start; }
  .hero,
  .work-layout { grid-template-columns: 1fr; }
  .prompt-panel { position: static; }
  .home-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .content { width: min(100% - 22px, 1500px); padding-top: 14px; }
  .page-title { padding: 18px; border-radius: 24px; }
  .hero { border-radius: 26px; }
  .quick-stats { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr; }
  .client-card,
  .task-card { grid-template-columns: 1fr; align-items: stretch; }
  .actions,
  .button-row { justify-content: stretch; }
  .actions .btn,
  .button-row .btn,
  .task-card .btn { flex: 1; }
  .stats-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}


/* V7 visual refresh */
body::before {
  content: "V6";
  position: fixed;
  right: 18px;
  bottom: 14px;
  z-index: 9999;
  font-weight: 1000;
  font-size: 12px;
  letter-spacing: .18em;
  color: rgba(255,255,255,.9);
  background: #0f172a;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  padding: 8px 12px;
  box-shadow: 0 12px 28px rgba(15,23,42,.22);
  pointer-events: none;
}
.app-header {
  position: sticky;
  top: 0;
  grid-template-columns: auto 1fr auto;
  background: rgba(15, 23, 42, .92);
  border-bottom: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 16px 40px rgba(15,23,42,.16);
}
.brand {
  min-width: 300px;
  background: linear-gradient(135deg, #020617, #064e3b 55%, #10b981);
}
.main-nav button { background: rgba(255,255,255,.08); color: rgba(255,255,255,.86); border-color: rgba(255,255,255,.12); }
.main-nav button.active { background: #ffffff; color: #064e3b; box-shadow: 0 12px 30px rgba(255,255,255,.14); }
.header-actions .btn.ghost { background: rgba(255,255,255,.08); color: white; border-color: rgba(255,255,255,.14); }
.header-actions .btn.primary { background: #10b981; border-color: #10b981; color: #052e22; }
.content { width: min(1440px, calc(100% - 34px)); padding-top: 22px; }
.page-title {
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(255,255,255,.96), rgba(236,253,245,.96));
}
.hero {
  background: linear-gradient(135deg, #020617, #0f172a 42%, #065f46 100%);
  border: 1px solid rgba(255,255,255,.1);
}
.home-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.home-card {
  border-radius: 34px;
  min-height: 260px;
  background: linear-gradient(180deg, #ffffff, #f0fdf4);
}
.home-card span { background: #0f172a; color: white; }
@media (max-width: 900px) {
  .app-header { grid-template-columns: 1fr; }
  .brand { width: 100%; min-width: 0; }
  .main-nav { justify-content: flex-start; }
  .header-actions { justify-content: flex-start; }
  .home-grid { grid-template-columns: 1fr; }
}

/* V7 automation additions */
body::before { content: "V7" !important; }
.automation-grid {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  gap: 18px;
  margin-bottom: 18px;
}
.automation-rules {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}
.automation-rules div,
.status-box {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 18px;
  padding: 14px;
}
.automation-rules strong,
.automation-rules span,
.status-box span {
  display: block;
}
.automation-rules span,
.status-box span,
.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.status-box { margin-top: 12px; }
.status-box.ok { background: #ecfdf5; border-color: #bbf7d0; }
.status-box.warn { background: #fff7ed; border-color: #fed7aa; }
.button-row.wrap { flex-wrap: wrap; }
.button-row.right { justify-content: flex-end; flex-wrap: wrap; }
.log-list { display: grid; gap: 10px; }
.log-item {
  border: 1px solid var(--line);
  border-left: 5px solid #94a3b8;
  border-radius: 18px;
  padding: 12px 14px;
  background: white;
  display: grid;
  gap: 4px;
}
.log-item.ok { border-left-color: #16a34a; background: #f0fdf4; }
.log-item.err { border-left-color: #dc2626; background: #fef2f2; }
.log-item strong { color: var(--text); }
.log-item span,
.log-item em { color: var(--muted); font-size: 13px; }
.log-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.log-links a { color: #047857; font-weight: 900; text-decoration: none; }
@media (max-width: 1050px) { .automation-grid { grid-template-columns: 1fr; } }

.send-panel .section-head.block p { max-width: 900px; }
.send-help,
.send-note,
.send-progress,
.send-result {
  border: 1px solid var(--line);
  background: #f8fbfa;
  border-radius: 18px;
  padding: 14px 16px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 16px;
}
.send-help strong { color: var(--green2); }
.send-note { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.send-progress { background: var(--green3); color: var(--green2); font-weight: 900; margin-top: 14px; }
.send-result { margin-top: 14px; background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.send-result.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.send-result h3 { margin: 0 0 6px; color: inherit; }
.send-result p { margin: 0 0 12px; }
.advanced-send {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: var(--surface2);
}
.advanced-send summary { cursor: pointer; font-weight: 1000; color: var(--green2); }
.advanced-send label { margin-top: 12px; }
.send-card { align-items: center; }

/* Production login and cleaner dashboard additions */
.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #0b1f1a 0%, #145846 52%, #178b69 100%);
}
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(440px, 100%);
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(255,255,255,.36);
  border-radius: 32px;
  padding: 34px;
  box-shadow: 0 35px 100px rgba(0,0,0,.28);
  text-align: center;
}
.login-card img { width: 82px; height: 82px; border-radius: 24px; object-fit: cover; box-shadow: var(--shadow2); }
.login-card h1 { margin: 18px 0 6px; font-size: 30px; letter-spacing: -.05em; }
.login-card p { margin: 0 0 24px; color: var(--muted); font-weight: 800; }
.login-form { display: grid; gap: 14px; text-align: left; }
.login-form label { display: grid; gap: 7px; font-weight: 900; color: #29483f; }
.login-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  outline: none;
  background: white;
}
.login-form input:focus { border-color: rgba(19,119,91,.55); box-shadow: 0 0 0 4px rgba(19,119,91,.1); }
.login-form button {
  border: 0;
  border-radius: 18px;
  padding: 14px 16px;
  color: white;
  background: linear-gradient(135deg, var(--green), var(--green2));
  font-weight: 1000;
  box-shadow: 0 18px 35px rgba(19,119,91,.24);
}
.login-error {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #991b1b;
  border-radius: 14px;
  padding: 10px 12px;
  text-align: center;
  font-weight: 900;
}
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.home-grid.clean .home-card { min-height: 190px; }
.home-grid.clean .home-card strong { margin-top: 18px; }
@media (max-width: 900px) { .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .dashboard-stats { grid-template-columns: 1fr; } }
