:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --dark: #0f172a;
  --brand: #059669;
  --brand-2: #047857;
  --brand-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); }
h2 { font-size: 20px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); background: var(--bad-soft); padding: 8px 10px; border-radius: 8px; margin: 0; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* Buttons and fields */
.btn { border: 1px solid var(--line-2); background: #fff; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); border-color: #fca5a5; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.ghost-dark { background: transparent; color: #cbd5e1; border-color: #334155; }
.btn.ghost-dark:hover { background: #1e293b; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.wide { width: 100%; }
.link { background: none; border: 0; color: var(--brand-2); cursor: pointer; padding: 4px 0; text-decoration: underline; }
.seg { display: inline-flex; background: #e2e8f0; padding: 3px; border-radius: 9px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: #fff; box-shadow: var(--shadow); color: var(--ink); }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 12px; color: var(--ink-2); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], input[type=search], input:not([type]), select, textarea {
  border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 9px; background: #fff; font-weight: 400; font-size: 14px; min-width: 0;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #6ee7b7; outline-offset: 0; border-color: var(--brand); }

/* Sign in */
.signin { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.signin-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; padding: 24px; }

/* Shell */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.topbar { background: var(--dark); color: #fff; display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; gap: 12px; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.brand small { font-weight: 500; color: #94a3b8; font-size: 12px; margin-left: 4px; }
.brand.big { font-size: 20px; color: var(--ink); }
.brand.big small { color: var(--muted); }
.logo { width: 34px; height: 34px; border-radius: 8px; background: #10b981; color: #022c22; display: grid; place-items: center; font-weight: 900; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { color: #cbd5e1; font-size: 13px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: #064e3b; color: #a7f3d0; border: 1px solid #047857; }
.badge.free { background: #422006; color: #fde68a; border-color: #a16207; }
.tabs { background: #fff; border-bottom: 1px solid var(--line); display: flex; gap: 2px; padding: 0 16px; overflow-x: auto; position: sticky; top: 54px; z-index: 19; }
.tabs button { border: 0; background: none; padding: 12px 12px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--brand-2); border-bottom-color: var(--brand); }
.count { background: var(--brand); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 6px; margin-left: 4px; }
.main { max-width: 1400px; margin: 0 auto; padding: 20px; }
.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.bar .grow { flex: 1; }
.locked { padding: 32px; text-align: center; }

/* Calendar */
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; font-weight: 700; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { background: #fff; border: 1px solid var(--line); border-radius: 8px; min-height: 118px; padding: 5px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; overflow: hidden; }
.day.out { background: #f8fafc; color: #94a3b8; }
.day.today { outline: 2px solid var(--brand); }
.day.weekend { background: #fafafa; }
.day.drop { background: var(--brand-soft); outline: 2px dashed var(--brand); }
.day-num { font-size: 12px; font-weight: 700; display: flex; justify-content: space-between; }
.pill { display: flex; align-items: center; gap: 4px; font-size: 12px; line-height: 1.25; padding: 3px 5px; border-radius: 5px; background: var(--c, #e2e8f0); border-left: 4px solid var(--c2, #94a3b8); cursor: grab; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pill span.t { overflow: hidden; text-overflow: ellipsis; }
.pill.open { background: #fff; border: 1px dashed #94a3b8; border-left: 4px dashed #94a3b8; }
.pill.done { opacity: .6; }
.pill.done .t { text-decoration: line-through; }
.pill.busy { background: #f1f5f9; color: var(--muted); border-left-color: #cbd5e1; cursor: default; font-style: italic; }
.pill .tm { font-weight: 700; }
.more { font-size: 11px; color: var(--muted); padding-left: 4px; }
.dots { display: inline-flex; gap: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); border: 1px solid rgba(0,0,0,.15); display: inline-block; flex: none; }

.week { display: grid; grid-template-columns: 150px repeat(7, 1fr); gap: 4px; }
.week .h { font-weight: 700; font-size: 12px; color: var(--muted); padding: 6px 4px; }
.week .h.today { color: var(--brand-2); }
.week .who-cell { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.week .slot { background: #fff; border: 1px solid var(--line); border-radius: 8px; min-height: 64px; padding: 4px; display: flex; flex-direction: column; gap: 4px; }
.week .slot.weekend { background: #fafafa; }
.week .slot.drop { background: var(--brand-soft); outline: 2px dashed var(--brand); }
.jcard { background: var(--c, #f1f5f9); border-left: 4px solid var(--c2, #94a3b8); border-radius: 6px; padding: 4px 6px; font-size: 12px; cursor: grab; }
.jcard.open { background: #fff; border: 1px dashed #94a3b8; }
.jcard.done { opacity: .6; }
.jcard b { display: block; }
.jcard .sub { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tables and lists */
table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 10px; border-bottom: 1px solid var(--line); background: #f8fafc; }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr.click:hover td { background: #f8fafc; cursor: pointer; }
.tablewrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: #f1f5f9; color: var(--ink-2); }
.tag.green { background: #d1fae5; color: #065f46; }
.tag.amber { background: var(--warn-soft); color: var(--warn); }
.tag.red { background: var(--bad-soft); color: var(--bad); }
.tag.blue { background: #dbeafe; color: #1e40af; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.tile { padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.tile:hover { border-color: var(--line-2); }
.section { padding: 14px; margin-bottom: 14px; }
.section h3 { display: flex; justify-content: space-between; align-items: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.rows > * + * { border-top: 1px solid var(--line); }
.rows > * { padding: 9px 0; }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.files a { display: block; padding: 6px 0; }

/* Modal */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(15, 23, 42, .55); }
.m-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.m-head h2 { font-size: 17px; }
.m-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.m-foot { display: flex; justify-content: space-between; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; }
.m-foot .right { display: flex; gap: 8px; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cols3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.people { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.lines { width: 100%; border-collapse: collapse; }
.lines td, .lines th { padding: 3px 4px; text-align: left; font-size: 12px; }
.lines input, .lines select { width: 100%; padding: 5px 6px; font-size: 13px; }
.note { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; color: var(--ink-2); }
.x { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--dark); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); display: flex; gap: 12px; align-items: center; z-index: 100; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); }
.toast button { background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 6px; padding: 3px 8px; cursor: pointer; }

@media (max-width: 800px) {
  .cols2, .cols3 { grid-template-columns: 1fr; }
  .week { grid-template-columns: 90px repeat(7, minmax(110px, 1fr)); overflow-x: auto; }
  .topbar .who { display: none; }
  .main { padding: 16px; }
}
