:root {
  --bg: #f1f1f1; --surface: #ffffff; --surface-2: #f7f7f7; --surface-3: #ebebeb; --border: #e3e3e3;
  --text: #303030; --text-2: #616161; --text-3: #8a8a8a;
  --accent: #303030; --accent-text: #ffffff;
  --crit-bg: #fee8eb; --crit: #8e1f0b; --warn-bg: #fff1e3; --warn: #5e4200;
  --ok-bg: #cdfee1; --ok: #0c5132; --info-bg: #eaf4ff; --info: #00527c;
  --magic-bg: #f0e9ff; --magic: #4b2e83; --neutral-bg: #e3e3e3; --neutral: #4a4a4a;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(26,26,26,.07), 0 1px 0 rgba(204,204,204,.5) inset, 0 -1px 0 rgba(0,0,0,.17) inset;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
ui-nav-menu { display: none; } /* App Bridge reads it and renders the menu in the Shopify sidebar */
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--info); }
.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.empty { padding: 32px 16px; text-align: center; color: var(--text-2); }
.muted { color: var(--text-2); } .faint { color: var(--text-3); }
.head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.head h1 { font-size: 20px; font-weight: 650; margin: 0; flex: 1; min-width: 160px; }
h2.sec-title { font-size: 14px; font-weight: 650; margin: 0; }

/* local nav (shown only outside Shopify, e.g. preview) */
.localnav { display: flex; gap: 4px; padding: 8px 16px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); }
.localnav a { text-decoration: none; color: var(--text-2); font-weight: 550; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.localnav a.active { background: var(--neutral-bg); color: var(--text); }

/* buttons */
.btn { appearance: none; border: 0; border-radius: 8px; padding: 6px 12px; font-weight: 550; cursor: pointer;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-text); box-shadow: 0 -1px 0 1px rgba(0,0,0,.8) inset, 0 0 0 1px #303030 inset; }
.btn.primary:hover { background: #1a1a1a; }
.btn.plain { box-shadow: none; background: transparent; color: var(--info); padding: 6px 8px; }
.btn.danger { color: var(--crit); }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-group { display: inline-flex; border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
.btn-group .btn { box-shadow: none; border-radius: 0; border-right: 1px solid var(--border); }
.btn-group .btn:last-child { border-right: 0; }
.btn-group .btn.on { background: var(--neutral-bg); }

/* cards & panels */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 14px 16px; }
.card-h { display: flex; align-items: center; gap: 4px 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-h h2 { flex: 1; }
.stack { display: grid; gap: 16px; }
.stack > *, .grid-2 > *, .grid-main > *, .metrics > * { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-main { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metric { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; text-align: left; border: 2px solid transparent; }
button.metric { cursor: pointer; }
.metric.active { border-color: var(--accent); }
.metric .lbl { color: var(--text-2); font-weight: 550; font-size: 12px; }
.metric .num { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.metric .sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.metric.crit .num { color: var(--crit); }

/* lists */
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); align-items: start; }
.item:last-child { border-bottom: 0; }
.item.click { cursor: pointer; } .item.click:hover { background: var(--surface-2); }
.item .ic { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--text-3); }
.item .ic.crit { background: #e51c00; } .item .ic.warn { background: #e8a400; } .item .ic.info { background: #2c6ecb; } .item .ic.ok { background: #29845a; }
.item .t { font-weight: 600; overflow-wrap: anywhere; }
.item .d { color: var(--text-2); grid-column: 2 / -1; overflow-wrap: anywhere; }
.item .r { color: var(--text-3); white-space: nowrap; font-size: 12px; }

.row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row .t { font-weight: 650; overflow-wrap: anywhere; }
.row .a { color: var(--text-2); grid-column: 1 / -1; overflow-wrap: anywhere; }
.row .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; grid-column: 1 / -1; color: var(--text-3); }
.row .when { color: var(--text-3); white-space: nowrap; }

.tabs { display: flex; gap: 4px; padding: 8px; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tab { border: 0; background: transparent; font-weight: 550; color: var(--text-2); padding: 6px 10px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--neutral-bg); color: var(--text); }
.tools { display: flex; gap: 8px; padding: 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tools input, .tools select { border: 1px solid #8a8a8a; border-radius: 8px; padding: 6px 10px; background: var(--surface); }
.tools input[type=search] { flex: 1; min-width: 160px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 8px; padding: 2px 8px; font-size: 12px; font-weight: 550; background: var(--neutral-bg); color: var(--neutral); white-space: nowrap; }
.b-urgent { background: #8e1f0b; color: #fff; } .b-high { background: var(--crit-bg); color: var(--crit); }
.b-medium { background: var(--warn-bg); color: var(--warn); } .b-low { background: var(--neutral-bg); color: var(--neutral); }
.b-to_do { background: var(--info-bg); color: var(--info); } .b-in_progress { background: var(--warn-bg); color: var(--warn); }
.b-waiting, .b-waiting_delivery, .b-waiting_approval { background: var(--magic-bg); color: var(--magic); }
.b-completed { background: var(--ok-bg); color: var(--ok); } .b-dismissed { background: var(--neutral-bg); color: var(--neutral); }
.b-review, .b-overdue { background: var(--warn-bg); color: var(--warn); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

/* banner */
.banner { display: flex; gap: 8px; align-items: flex-start; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; background: var(--surface); box-shadow: var(--shadow); color: var(--text-2); }
.banner.crit { background: var(--crit-bg); color: var(--crit); box-shadow: none; }
.banner.warn { background: var(--warn-bg); color: var(--warn); box-shadow: none; }
.banner .grow { flex: 1; min-width: 0; }

/* sheet */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; z-index: 10; }
.scrim.open { display: flex; }
.sheet { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 640px; box-shadow: 0 20px 40px rgba(0,0,0,.25); }
.sheet-h { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); }
.sheet-h h2 { margin: 0; font-size: 16px; font-weight: 650; flex: 1; overflow-wrap: anywhere; }
.sheet-b { padding: 16px; display: grid; gap: 14px; }
.sheet-f { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sheet-f .left { margin-right: auto; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.sec h3 { margin: 0 0 4px; font-size: 13px; font-weight: 650; }
.sec p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.callout { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 8px 12px; }
label.f { display: grid; gap: 4px; font-weight: 550; }
label.f input, label.f select, label.f textarea { font-weight: 400; border: 1px solid #8a8a8a; border-radius: 8px; padding: 6px 10px; background: var(--surface); width: 100%; min-width: 0; }
label.f textarea { min-height: 72px; resize: vertical; }
label.chk { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--neutral-bg); border-color: #b5b5b5; }
.chip.off { opacity: .45; }
.links { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hist { color: var(--text-2); font-size: 12px; display: grid; gap: 2px; }

/* calendar */
.cal-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.cal-head .title { font-size: 15px; font-weight: 650; flex: 1; min-width: 140px; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); }
.month .dow { padding: 6px 8px; font-size: 12px; color: var(--text-2); font-weight: 600; border-bottom: 1px solid var(--border); }
.month .cell { min-height: 104px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px; display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-width: 0; }
.month .cell:nth-child(7n) { border-right: 0; }
.month .cell.other { background: var(--surface-2); }
.month .cell.today .dnum { background: var(--accent); color: #fff; }
.month .cell.drop-target { background: var(--info-bg); }
.dnum { font-size: 12px; font-weight: 600; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.ev { display: flex; align-items: center; gap: 4px; font-size: 12px; border-radius: 6px; padding: 1px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; border-left: 3px solid var(--c, #6d7175); background: color-mix(in srgb, var(--c, #6d7175) 12%, white); min-width: 0; }
.ev.task { background: var(--surface-2); }
.ev.done { text-decoration: line-through; opacity: .6; }
.ev .tm { color: var(--text-2); flex: none; margin-right: 2px; }
.ev span.lbl { overflow: hidden; text-overflow: ellipsis; }
.more { font-size: 12px; color: var(--text-2); padding: 0 6px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); }
.week .col { border-right: 1px solid var(--border); min-height: 360px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.week .col:last-child { border-right: 0; }
.week .col.today { background: #fafafa; }
.week .col.drop-target { background: var(--info-bg); }
.week .wh { font-size: 12px; font-weight: 600; color: var(--text-2); padding-bottom: 4px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; justify-content: space-between; cursor: pointer; }
.week .wh.today { color: var(--text); }
.week .ev { white-space: normal; display: block; }
.agenda .day { padding: 8px 16px 4px; font-weight: 650; background: var(--surface-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.agenda .day.today { background: var(--info-bg); }
.agenda .ag { display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: center; }
.agenda .ag:hover { background: var(--surface-2); }
.agenda .ag .tm { color: var(--text-2); font-variant-numeric: tabular-nums; }
.agenda .ag .ttl { display: flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.ev[draggable=true] { cursor: grab; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #303030; color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 20; }
.err { background: var(--crit-bg); color: var(--crit); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { text-align: left; padding: 8px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.tbl th { color: var(--text-2); font-weight: 600; font-size: 12px; }
table.tbl tr:last-child td { border-bottom: 0; }
.num-r { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-main { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 6px; }
  .fgrid { grid-template-columns: 1fr; }
  .month .cell { min-height: 64px; padding: 2px; }
  .month .ev .tm { display: none; }
  .month .ev { padding: 1px 3px; font-size: 11px; }
  .week { grid-template-columns: 1fr; }
  .week .col { min-height: 0; border-right: 0; border-bottom: 1px solid var(--border); }
  table.tbl th, table.tbl td { padding: 8px 10px; }
}
