/* ═══════════════════════════════════════════════════════════════
   ANDHRA DAIRY — Admin panel styles
   Brand: deep farm green #006134 · cream #F6F1E3 · gold #D9A441
   ═══════════════════════════════════════════════════════════════ */

:root {
  --green-900: #00331d;
  --green-700: #006134;
  --green-600: #0a6b3a;
  --green-100: #e4efe8;
  --green-50: #f2f7f4;
  --gold: #d9a441;
  --gold-dark: #b8872f;
  --cream: #f6f1e3;
  --ink-900: #142018;
  --ink-600: #3d4a41;
  --ink-400: #74817a;
  --ink-300: #9aa69f;
  --white: #ffffff;
  --border: #e6e0d2;
  --red: #c0392b;
  --amber: #b7791f;
  --blue: #2c6e9b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 32, 24, .05), 0 8px 24px rgba(20, 32, 24, .06);
  --font-serif: 'Fraunces', Georgia, serif;
  --font-sans: 'Inter', system-ui, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  background: #f4f1e9;
  color: var(--ink-900);
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ── Shell layout ── */
.shell { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--green-900) 0%, #01230f 100%);
  color: #dceadf;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.sidebar-brand img { border-radius: 8px; }
.sidebar-brand strong { display: block; font-family: var(--font-serif); font-size: 16px; color: #fff; letter-spacing: .2px; }
.sidebar-brand span { font-size: 11px; color: #9dc3a8; text-transform: uppercase; letter-spacing: 1.4px; }

.sidebar-nav { margin-top: 16px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: #b9cfc0; font-weight: 500; font-size: 13.5px;
  transition: background .18s, color .18s;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar-nav a.active { background: var(--green-600); color: #fff; }
.nav-ico { width: 18px; text-align: center; opacity: .85; font-size: 14px; }
.sidebar-nav .badge {
  margin-left: auto; background: var(--gold); color: var(--green-900);
  border-radius: 999px; font-size: 11px; font-style: normal; font-weight: 700;
  padding: 1px 7px; min-width: 18px; text-align: center;
}

.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 14px; }
.sidebar-foot .btn-ghost {
  display: block; text-align: center; padding: 9px 10px; border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, .25); color: #fff; font-weight: 600; font-size: 13px;
  transition: background .18s;
}
.sidebar-foot .btn-ghost:hover { background: rgba(255, 255, 255, .1); }
.sidebar-foot p { font-size: 11px; color: #8fb39a; text-align: center; margin-top: 10px; }

/* ── Main ── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 32px; background: var(--cream);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-family: var(--font-serif); font-weight: 600; font-size: 24px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.conn { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-400); font-weight: 500; }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); display: inline-block; }
.conn.ok i { background: var(--green-600); }
.conn.bad i { background: var(--red); }

#view { padding: 28px 32px 60px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; cursor: pointer; transition: all .16s;
}
.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-900); }
.btn-gold { background: var(--gold); color: var(--green-900); }
.btn-gold:hover { background: var(--gold-dark); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--ink-600); }
.btn-ghost:hover { border-color: var(--ink-300); }
.btn-danger { background: transparent; border-color: #e5c5c0; color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── Cards ── */
.card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px;
}
.card h2 { font-family: var(--font-serif); font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.card .card-sub { color: var(--ink-400); font-size: 13px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-head h2 { margin: 0; }

/* ── Stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; right: -18px; top: -18px; width: 70px; height: 70px;
  border-radius: 50%; background: var(--green-100); opacity: .7;
}
.stat-card .stat-value { font-family: var(--font-serif); font-size: 30px; font-weight: 700; color: var(--green-700); line-height: 1.1; }
.stat-card .stat-label { color: var(--ink-400); font-size: 12.5px; margin-top: 6px; font-weight: 500; }
.stat-card.gold .stat-value { color: var(--gold-dark); }
.stat-card.gold::after { background: #f6ecd4; }
.stat-card.blue .stat-value { color: var(--blue); }
.stat-card.blue::after { background: #e3edf5; }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.red::after { background: #f9e8e6; }

/* ── Grids ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; padding: 10px 12px; color: var(--ink-400); font-weight: 600;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid #f0ece2; vertical-align: top; }
tr:last-child td { border-bottom: none; }
td .muted { color: var(--ink-400); font-size: 12.5px; }
td .phone { font-weight: 600; color: var(--green-700); }

/* status pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.pill.new { background: #e8f0fb; color: var(--blue); }
.pill.contacted { background: #fdf1da; color: var(--amber); }
.pill.converted { background: var(--green-100); color: var(--green-700); }
.pill.closed { background: #eeeae0; color: var(--ink-400); }
.pill.active { background: var(--green-100); color: var(--green-700); }
.pill.paused { background: #eeeae0; color: var(--ink-400); }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-600); }
.field label .hint { font-weight: 400; color: var(--ink-400); }
input[type="text"], input[type="tel"], input[type="email"], input[type="number"], input[type="url"], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13.5px; color: var(--ink-900); background: #fcfbf7;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(0, 97, 52, .12); background: #fff;
}
textarea { min-height: 84px; resize: vertical; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--green-700); }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }

/* toggle switch */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle .track { width: 40px; height: 22px; border-radius: 999px; background: #d6d2c6; position: relative; transition: background .18s; }
.toggle .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .18s;
}
.toggle input:checked + .track { background: var(--green-600); }
.toggle input:checked + .track::after { left: 21px; }

/* ── Lists (editor rows) ── */
.editor-row {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 12px;
  background: #fcfbf7;
}
.editor-row .row-main { display: flex; flex-direction: column; gap: 4px; }
.editor-row .row-title { font-weight: 600; font-size: 14px; }
.editor-row .row-sub { color: var(--ink-400); font-size: 12.5px; }
.editor-row .row-actions { display: flex; gap: 8px; }
.repeater-actions { display: flex; gap: 10px; margin-top: 6px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs button {
  background: none; border: none; padding: 10px 16px; font-weight: 600; font-size: 13px;
  color: var(--ink-400); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--green-700); border-bottom-color: var(--green-700); }

/* ── Media grid ── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.media-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fcfbf7;
}
.media-item .thumb { height: 110px; display: flex; align-items: center; justify-content: center; background: #f0ece2; }
.media-item .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.media-item .meta { padding: 8px 10px; }
.media-item .meta .name { font-size: 11.5px; font-weight: 600; word-break: break-all; }
.media-item .meta .size { font-size: 11px; color: var(--ink-400); }
.media-item .meta .actions { display: flex; gap: 6px; margin-top: 6px; }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 34px; text-align: center;
  color: var(--ink-400); cursor: pointer; transition: all .18s; background: #fcfbf7; margin-bottom: 18px;
}
.dropzone:hover, .dropzone.drag { border-color: var(--green-600); background: var(--green-50); color: var(--green-700); }
.dropzone strong { display: block; font-size: 15px; color: var(--ink-600); margin-bottom: 4px; }

/* ── Empty states ── */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-400); }
.empty .big { font-size: 30px; margin-bottom: 8px; }
.empty p { max-width: 360px; margin: 0 auto; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--green-900); color: #fff; padding: 12px 22px; border-radius: 999px;
  font-weight: 600; font-size: 13.5px; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  opacity: 0; transition: all .3s; z-index: 100; pointer-events: none; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }

/* ── Login (token gate) ── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(60% 80% at 50% 0%, #0a6b3a 0%, var(--green-900) 60%, #00200f 100%);
  padding: 24px;
}
.login-card {
  background: #fff; border-radius: 20px; padding: 40px; width: 100%; max-width: 400px;
  box-shadow: 0 24px 60px rgba(0,0,0,.4); text-align: center;
}
.login-card img { border-radius: 12px; margin-bottom: 14px; }
.login-card h1 { font-family: var(--font-serif); font-size: 24px; margin-bottom: 4px; }
.login-card p { color: var(--ink-400); font-size: 13.5px; margin-bottom: 20px; }
.login-card input { text-align: center; letter-spacing: 1px; margin-bottom: 14px; }
.login-card .note { font-size: 12px; color: var(--ink-300); margin-top: 14px; }

/* ── Misc ── */
.spark { display: inline-flex; gap: 3px; }
.spark i { width: 7px; height: 18px; border-radius: 2px; background: var(--green-100); }
.spark i.on { background: var(--green-600); }
.bar-row { display: grid; grid-template-columns: 110px 1fr 44px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.bar-row .bar { height: 14px; border-radius: 4px; background: var(--green-100); overflow: hidden; }
.bar-row .bar span { display: block; height: 100%; background: var(--green-600); border-radius: 4px; }
.bar-row .num { text-align: right; font-weight: 600; color: var(--ink-600); }

.hidden { display: none !important; }

@media (max-width: 860px) {
  .sidebar { width: 66px; padding: 16px 8px; }
  .sidebar-brand div, .sidebar-nav a span:not(.nav-ico), .sidebar-foot p, .sidebar-foot .btn-ghost { display: none; }
  .sidebar-nav a { justify-content: center; }
  .sidebar-nav .badge { position: absolute; margin-left: 34px; margin-top: -20px; }
  .topbar { padding: 16px 18px; }
  #view { padding: 20px 18px 50px; }
}
