/* Horizon Ag & Turf — light theme built on the John Deere palette sampled from their logo. */
:root {
  --green: #367C2B;
  --green-hover: #2c6623;
  --green-deep: #24611D;
  --green-dark: #185733;
  --green-wash: #eef5ec;
  --green-wash-2: #e2eede;
  --yellow: #FFDE00;
  --yellow-deep: #FECC07;

  --bg: #ffffff;
  --surface: #f6f8f5;
  --surface-2: #eef1ed;
  --border: #e0e5df;
  --border-strong: #c9d2c7;
  --ink: #171c16;
  --ink-2: #3f4a3d;
  --muted: #6b776a;
  --danger: #b3261e;
  --danger-wash: #fdecea;
  --warn: #8a6100;
  --warn-wash: #fff6df;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 18, .05), 0 4px 14px rgba(20, 30, 18, .05);
  --shadow-lg: 0 8px 30px rgba(20, 30, 18, .14);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--green); }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; font-weight: 650; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ── layout ───────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
/* Grid children default to min-width:auto, which lets wide content push the page sideways. */
.app > * { min-width: 0; }

.sidebar {
  background: var(--bg); border-right: 1px solid var(--border);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { padding: 0 6px; }
.sidebar .logo img { width: 100%; height: auto; display: block; }
.sidebar .sub {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); margin-top: 10px; padding-left: 6px; font-weight: 600;
}
nav { display: flex; flex-direction: column; gap: 2px; }
nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ink-2); cursor: pointer; text-align: left; font-weight: 500;
}
nav button:hover { background: var(--surface); color: var(--ink); }
nav button.active { background: var(--green-wash); color: var(--green-deep); font-weight: 600; }
nav button .ico { width: 18px; text-align: center; opacity: .85; }
nav .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.sidebar footer { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 6px; }
.sidebar footer .who { color: var(--ink-2); font-weight: 600; }
.sidebar footer button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; text-decoration: underline; }

.main { padding: 28px 32px 80px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page-head .grow { flex: 1; }
.page-head p { margin: 5px 0 0; color: var(--muted); }

/* ── primitives ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--ink); font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--green-hover); border-color: var(--green-hover); }
.btn.danger { color: var(--danger); border-color: #e7c9c6; }
.btn.danger:hover { background: var(--danger-wash); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface); }

.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card .card-head .grow { flex: 1; }
.card .card-body { padding: 16px; }

.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); } /* fits all six on one row */
.stat { padding: 14px 16px; }
.stat .n { font-size: 28px; font-weight: 680; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.alert .n { color: var(--warn); }

label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
input[type=text], input[type=url], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-wash); }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox input { width: auto; margin: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
}
.badge.green { background: var(--green-wash); color: var(--green-deep); }
.badge.yellow { background: var(--warn-wash); color: var(--warn); }
.badge.red { background: var(--danger-wash); color: var(--danger); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: none; }
.dot.on { background: #2e9e3f; box-shadow: 0 0 0 3px rgba(46,158,63,.16); }
.dot.off { background: #c2c9c1; }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; opacity: .55; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
tbody tr:last-child td { border-bottom: 0; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ── login ────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--surface); padding: 20px; }
.login { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 30px; }
.login .logo { margin-bottom: 22px; }
.login h1 { font-size: 20px; margin-bottom: 4px; }
.login p.sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.login .btn { width: 100%; margin-top: 6px; }
.login .brandbar { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--green) 0 60%, var(--yellow) 60% 100%); margin-bottom: 24px; }
.err { background: var(--danger-wash); color: var(--danger); border: 1px solid #f0cdc9; padding: 9px 12px; border-radius: 8px; font-size: 13.5px; margin-bottom: 14px; }

/* ── screens ──────────────────────────────────────────────── */
.location-block { margin-bottom: 26px; }
.location-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.location-head .addr { color: var(--muted); font-size: 13px; }

.screen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 14px; }
.screen-card { overflow: hidden; cursor: pointer; transition: box-shadow .12s, border-color .12s; }
.screen-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.screen-card .shot {
  aspect-ratio: 16/9; background: var(--surface-2) center/cover no-repeat;
  display: grid; place-items: center; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--border);
}
.screen-card .shot.portrait { aspect-ratio: 4/5; }
.screen-card .meta { padding: 12px 14px; }
.screen-card .title { display: flex; align-items: center; gap: 8px; font-weight: 620; }
.screen-card .title .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-card .playing { color: var(--muted); font-size: 13px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-card .tags { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }

/* ── content gallery ──────────────────────────────────────── */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 340px; }
.toolbar .search input { width: 100%; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.tile { overflow: hidden; display: flex; flex-direction: column; }
.tile .thumb {
  aspect-ratio: 16/9; background: var(--surface-2); position: relative;
  display: grid; place-items: center; border-bottom: 1px solid var(--border); overflow: hidden;
}
.tile .thumb img, .tile .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .thumb .glyph { font-size: 34px; opacity: .4; }
.tile .thumb .corner { position: absolute; top: 8px; right: 8px; }
.tile .body { padding: 11px 12px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.tile .name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .sub { color: var(--muted); font-size: 12.5px; }
.tile .acts { display: flex; gap: 5px; padding: 9px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.tile .acts .btn { flex: 1; }
.tile.sel { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-wash); }

.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 30px; text-align: center; color: var(--muted); background: var(--surface);
  cursor: pointer; transition: .12s;
}
.dropzone.over { border-color: var(--green); background: var(--green-wash); color: var(--green-deep); }
.dropzone .big { font-size: 30px; margin-bottom: 6px; }

/* ── playlist editor ──────────────────────────────────────── */
.pl-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 9px; background: #fff; margin-bottom: 8px;
}
.pl-item.dragging { opacity: .35; }
.pl-item.over { border-color: var(--green); box-shadow: 0 -2px 0 var(--green) inset; }
.pl-item .handle { cursor: grab; color: var(--border-strong); font-size: 17px; padding: 0 2px; user-select: none; }
.pl-item .handle:active { cursor: grabbing; }
.pl-item .pos { width: 22px; text-align: center; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.pl-item .mini { width: 62px; height: 36px; border-radius: 5px; background: var(--surface-2) center/cover no-repeat; flex: none; display: grid; place-items: center; font-size: 16px; }
.pl-item .info { flex: 1; min-width: 0; }
.pl-item .info .n { font-weight: 570; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-item .info .s { font-size: 12.5px; color: var(--muted); }
.pl-item .dur { width: 92px; flex: none; }
.pl-item .dur input { text-align: right; padding: 5px 8px; }
.pl-item .full { width: 92px; flex: none; text-align: right; font-size: 12.5px; color: var(--muted); }

.sticky-bar {
  position: sticky; bottom: 0; margin: 16px -16px -16px; padding: 12px 16px;
  background: #fff; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; border-radius: 0 0 var(--radius) var(--radius);
}
.sticky-bar .grow { flex: 1; }

/* ── modal ────────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(18, 26, 16, .42);
  display: grid; place-items: center; padding: 24px; z-index: 50;
}
.modal {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column;
}
.modal.wide { max-width: 880px; }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.modal-head .grow { flex: 1; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.modal-foot .grow { flex: 1; }

.days { display: flex; gap: 6px; }
.days button {
  flex: 1; padding: 7px 0; border-radius: 7px; border: 1px solid var(--border-strong);
  background: #fff; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.days button.on { background: var(--green); border-color: var(--green); color: #fff; }

/* ── toast ────────────────────────────────────────────────── */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 15px; border-radius: 9px;
  box-shadow: var(--shadow-lg); font-size: 14px; max-width: 400px;
  display: flex; gap: 9px; align-items: flex-start; animation: rise .16s ease-out;
}
.toast.ok { background: var(--green-deep); }
.toast.err { background: #8f2019; }
@keyframes rise { from { transform: translateY(8px); opacity: 0 } }

.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; flex: none;
}
.spinner.dark { border-color: var(--border-strong); border-top-color: var(--green); }
@keyframes spin { to { transform: rotate(360deg) } }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  /* Collapse the rail into a compact header + a scrollable tab strip. */
  .sidebar {
    position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border);
    padding: 14px 14px 0; gap: 12px;
  }
  .sidebar .logo img { max-width: 210px; }
  .sidebar .sub { display: none; }
  nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 8px; scrollbar-width: none; min-width: 0; }
  nav::-webkit-scrollbar { display: none; }
  nav button { width: auto; white-space: nowrap; padding: 8px 12px; }
  nav .count { display: none; }
  .sidebar footer {
    margin-top: 0; order: -1; display: flex; align-items: center; gap: 10px;
    padding: 0 0 4px;
  }
  .sidebar footer .who { flex: 1; }
  .sidebar footer > div:nth-child(2), .sidebar footer > div:last-child { display: none; }

  .main { padding: 20px 16px 60px; }
  .page-head { flex-wrap: wrap; }
  .grid { grid-template-columns: 1fr !important; }
  .row { flex-direction: column; gap: 0; }
  .modal-bg { padding: 12px; }
  .pl-item { flex-wrap: wrap; }
  .pl-item .dur, .pl-item .full { width: auto; }
}
