/* ============================================================
   Yielders Clones — Ops App styles
   Reskin guide: change the --brand variables below and the
   font stack. Everything else keys off these values.
   ============================================================ */
:root {
    --brand: #2e7d32;          /* primary green */
    --brand-dark: #1b5e20;
    --brand-light: #e8f5e9;
    --accent: #f9a825;         /* warm amber for warnings/due */
    --danger: #c62828;
    --ink: #212121;
    --muted: #757575;
    --bg: #f5f7f5;
    --card: #ffffff;
    --border: #dfe5df;
    --input-bg: #ffffff;
    --hover-row: #fafcfa;
    --amber-bg: #fff8e1;
    --amber-fg: #f57f17;
    --ok-bg: #e8f5e9;
    --ok-fg: #1b5e20;
    --err-bg: #ffebee;
    --err-fg: #b71c1c;
    --info-bg: #e3f2fd;
    --info-fg: #0d47a1;
    --radius: 10px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Dark mode: flipped via the 🌙/☀️ toggle in the top bar (saved per browser). */
[data-theme="dark"] {
    --brand: #43a047;
    --brand-dark: #2e7d32;
    --brand-light: #1b3a1f;
    --accent: #ffca28;
    --danger: #ef5350;
    --ink: #e8eae8;
    --muted: #9aa39a;
    --bg: #121714;
    --card: #1c231e;
    --border: #2c352d;
    --input-bg: #242c25;
    --hover-row: #222a23;
    --amber-bg: #3a2f10;
    --amber-fg: #ffca28;
    --ok-bg: #14301a;
    --ok-fg: #81c784;
    --err-bg: #3a1414;
    --err-fg: #ef9a9a;
    --info-bg: #10233a;
    --info-fg: #90caf9;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
}

/* ---------- Top bar ---------- */
.topbar {
    background: var(--brand-dark);
    color: #fff;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.nav { display: flex; gap: 0.25rem; flex-wrap: wrap; flex: 1; }
.nav a {
    color: #dcedc8; text-decoration: none; padding: 0.35rem 0.7rem;
    border-radius: 6px; font-size: 0.92rem;
}
.nav a:hover { background: rgba(255,255,255,0.12); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav-group { position: relative; }
.nav-parent { background: none; border: 0; color: #dcedc8; padding: 0.35rem 0.7rem; border-radius: 6px; font-size: 0.92rem; cursor: pointer; font-family: inherit; }
.nav-parent:hover { background: rgba(255,255,255,0.12); color: #fff; }
.nav-group.active > .nav-parent { background: var(--brand); color: #fff; }
.nav-dropdown { display: none; position: absolute; top: 100%; left: 0; min-width: 13rem; background: var(--brand-dark); border-radius: 8px; padding: 0.35rem; box-shadow: 0 8px 24px rgba(0,0,0,0.35); z-index: 60; }
.nav-dropdown a { display: block; }
.nav-group.open .nav-dropdown { display: block; }
@media (hover: hover) { .nav-group:hover .nav-dropdown { display: block; } }

/* ---------- Global search ---------- */
.gsearch { position: relative; }
.gsearch input {
    background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.25);
    color: #fff; border-radius: 6px; padding: 0.35rem 0.7rem; font-size: 0.9rem;
    width: 13rem; font-family: inherit;
}
.gsearch input::placeholder { color: rgba(255,255,255,0.65); }
.gsearch input:focus { outline: none; background: rgba(255,255,255,0.22); width: 17rem; }
.gsearch-drop {
    position: absolute; top: calc(100% + 6px); right: 0; width: 22rem; max-height: 24rem;
    overflow-y: auto; background: var(--card); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.3); z-index: 70; padding: 0.3rem;
}
.gsearch-group { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0.45rem 0.6rem 0.15rem; }
.gsearch-drop a { display: block; padding: 0.45rem 0.6rem; border-radius: 6px; text-decoration: none; color: var(--text); }
.gsearch-drop a:hover, .gsearch-drop a.sel { background: var(--brand); color: #fff; }
.gsearch-drop a small { display: block; font-size: 0.78rem; opacity: 0.75; }
.gsearch-all { border-top: 1px solid var(--border); margin-top: 0.3rem; padding-top: 0.3rem; }
@media (max-width: 760px) { .gsearch input { width: 8rem; } .gsearch input:focus { width: 10rem; } }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; white-space: nowrap; }
.user-name { font-size: 0.85rem; color: #dcedc8; }
.user-name em { font-style: normal; opacity: 0.8; }
.nav-toggle { display: none; background: none; border: 1px solid rgba(255,255,255,0.4); color: #fff; border-radius: 6px; padding: 0.3rem 0.6rem; font-size: 1.1rem; cursor: pointer; }
.theme-toggle { background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.25); color: #fff; border-radius: 6px; padding: 0.3rem 0.55rem; font-size: 1rem; cursor: pointer; line-height: 1; }
.theme-toggle:hover { background: rgba(255,255,255,0.22); }
.theme-toggle-float { position: fixed; top: 1rem; right: 1rem; z-index: 100; }

/* ---------- Layout ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.page-title { margin: 0.2rem 0 1.2rem; font-size: 1.6rem; }
.footer { text-align: center; color: var(--muted); padding: 1.5rem; font-size: 0.85rem; }

/* ---------- Cards / grids ---------- */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1.2rem;
}
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat { text-align: center; }
a.stat { text-decoration: none; color: inherit; transition: transform .12s ease, box-shadow .12s ease; }
a.stat:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.10); }
.stat .num { font-size: 2rem; font-weight: 700; color: var(--brand-dark); }
.stat .lbl { color: var(--muted); font-size: 0.9rem; }
.stat.warn .num { color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.data th, table.data td { padding: 0.55rem 0.6rem; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; white-space: nowrap; }
table.data tr:hover td { background: var(--hover-row); }

/* ---------- Forms ---------- */
label { display: block; margin-bottom: 0.7rem; font-size: 0.92rem; font-weight: 600; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="date"], input[type="datetime-local"], select, textarea {
    display: block; width: 100%; margin-top: 0.25rem; padding: 0.55rem 0.65rem;
    border: 1px solid var(--border); border-radius: 6px; font-size: 1rem; font-family: var(--font);
    background: var(--input-bg); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
fieldset.card legend { font-weight: 700; padding: 0 0.4rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.checkline { display: flex; align-items: center; gap: 0.5rem; font-weight: normal; }
.checkline input { width: auto; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; background: var(--brand); color: #fff; border: none;
    padding: 0.55rem 1.1rem; border-radius: 6px; font-size: 0.95rem; cursor: pointer;
    text-decoration: none; font-family: var(--font);
}
.btn:hover { background: var(--brand-dark); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8e0000; }
.btn-ghost { background: var(--card); color: var(--brand-dark); border: 1px solid var(--brand); }
.btn-ghost:hover { background: var(--brand-light); }
.inline-form { display: inline; }

/* ---------- Flash messages ---------- */
.flash { padding: 0.7rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.flash-ok { background: var(--ok-bg); border: 1px solid var(--ok-fg); color: var(--ok-fg); }
.flash-err { background: var(--err-bg); border: 1px solid var(--err-fg); color: var(--err-fg); }

/* ---------- Badges / pills ---------- */
.badge {
    display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px;
    font-size: 0.8rem; font-weight: 600; background: var(--border); color: var(--ink);
}
.badge-green { background: var(--ok-bg); color: var(--ok-fg); }
.badge-amber { background: var(--amber-bg); color: var(--amber-fg); }
.badge-red { background: var(--err-bg); color: var(--err-fg); }
.badge-blue { background: var(--info-bg); color: var(--info-fg); }

/* ---------- Checklist (batch stages) ---------- */
.stage-list { list-style: none; padding: 0; margin: 0; }
.stage-list li {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.6rem 0; border-bottom: 1px solid var(--border);
}
.stage-list li:last-child { border-bottom: none; }
.stage-list input[type="checkbox"] { width: 1.3rem; height: 1.3rem; accent-color: var(--brand); }
.stage-meta { margin-left: auto; font-size: 0.82rem; color: var(--muted); text-align: right; }

/* ---------- Comments ---------- */
.comment { border-bottom: 1px solid var(--border); padding: 0.6rem 0; }
.comment:last-child { border-bottom: none; }
.comment .who { font-weight: 700; font-size: 0.9rem; }
.comment .when { color: var(--muted); font-size: 0.8rem; margin-left: 0.5rem; }
.comment p { margin: 0.3rem 0 0; }

/* ---------- Key/value ---------- */
dl.kv { display: grid; grid-template-columns: 180px 1fr; gap: 0.3rem 1rem; margin: 0; }
dl.kv dt { font-weight: 600; color: var(--muted); }
dl.kv dd { margin: 0; }

/* ---------- Login ---------- */
.login-wrap { max-width: 380px; margin: 8vh auto; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; box-shadow: 0 4px 18px rgba(0,0,0,0.06); }
.login-card h1 { margin-top: 0; text-align: center; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* ============================================================
   TAGS — color-coded digital labels.
   ============================================================ */
.tag-chip {
    display: inline-block; padding: 0.2rem 0.7rem; border-radius: 999px;
    font-size: 0.82rem; font-weight: 600; text-decoration: none; margin: 0.1rem;
}
.tag-chip-active { box-shadow: 0 0 0 2px currentColor; }
.tag-picker { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag-pick {
    display: inline-flex; align-items: center; gap: 0.4rem;
    border: 1px solid var(--border); border-radius: 999px;
    padding: 0.3rem 0.8rem; font-weight: normal; font-size: 0.9rem; cursor: pointer;
    margin: 0;
}
.tag-pick input { width: auto; margin: 0; }
.dot { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 50%; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .nav-toggle { display: block; }
    .nav { display: none; width: 100%; flex-direction: column; }
    .nav.open { display: flex; }
    .userbox { margin-left: 0; }
    .topbar { flex-wrap: wrap; }
    dl.kv { grid-template-columns: 1fr; }
    dl.kv dt { margin-top: 0.4rem; }
}

/* ---------- Drag & drop (notes board) ---------- */
.dnd-handle {
    cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
    color: var(--muted, #888); letter-spacing: -2px; padding: 0 .35rem;
    font-size: .9rem; line-height: 1;
}
.dnd-handle:active { cursor: grabbing; }
.dnd-card { position: relative; }
.dnd-dragging { opacity: .35; }
.dnd-ghost {
    position: fixed; z-index: 9999; pointer-events: none; margin: 0;
    box-shadow: 0 12px 32px rgba(0,0,0,.25); transform: rotate(1.5deg);
    opacity: .95;
}
.dnd-drop-hint { outline: 2px dashed var(--brand); outline-offset: 3px; border-radius: 8px; }
.dnd-tabs { display: flex; flex-wrap: wrap; gap: .25rem; }
.dnd-tab { position: relative; }

/* ---------- Printable tray labels ---------- */
.label-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }
.label-card {
    border: 1px dashed var(--border); border-radius: 8px; padding: .6rem;
    text-align: center; background: #fff; color: #111; break-inside: avoid;
}
.label-title { font-weight: 700; margin-bottom: .3rem; font-size: .9rem; }
.label-card svg { max-width: 100%; height: auto; }
.label-code { font-family: monospace; letter-spacing: 2px; margin-top: .25rem; font-size: .85rem; }

/* ---------- Web3 polish: rainbow flare, glow, motion ---------- */
@property --flare-angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }

.rainbow-focus { transition: box-shadow .25s ease; }
.rainbow-focus:focus {
    outline: none;
    border: 2px solid transparent !important;
    background:
        linear-gradient(var(--card, #fff), var(--card, #fff)) padding-box,
        conic-gradient(from var(--flare-angle),
            #ff0080, #ff8c00, #ffee00, #00e676, #00b0ff, #7c4dff, #ff0080) border-box;
    animation: flare-spin 2.5s linear infinite;
    box-shadow: 0 0 18px rgba(124, 77, 255, .35);
}
@keyframes flare-spin { to { --flare-angle: 360deg; } }

.btn { transition: transform .12s ease, box-shadow .2s ease, background .2s ease; }
.btn:hover { box-shadow: 0 0 14px rgba(46, 125, 50, .45); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn-primary:hover {
    box-shadow: 0 0 18px rgba(124, 77, 255, .55), 0 0 4px rgba(255, 0, 128, .4);
}

.card { transition: transform .18s ease, box-shadow .25s ease; }

.stat-num { display: inline-block; min-width: 2ch; }

.shimmer {
    background: linear-gradient(90deg, var(--border) 25%, var(--card) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: 6px; color: transparent !important;
}
@keyframes shimmer { to { background-position: -200% 0; } }

@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
main > .card:first-of-type, main > h1 { animation: rise-in .35s ease both; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
