:root {
  /* Automation Gallery brand: red #C7222D, dark grey #3F3F40, light grey #E6E7E8, Lato */
  --bg: #f4f4f6; --card: #ffffff; --text: #231f20; --ink: #3f3f40; --muted: #6d6e71; --line: #e6e7e8;
  --brand: #C7222D; --brand-dark: #9f1b24; --brand-soft: #f9e9ea; --border: #8c8e91; --on-brand: #ffffff;
  --red: #c7222d; --red-soft: #fae9ea; --amber: #b45309; --amber-soft: #fef3c7; --green: #15803d; --green-soft: #dcfce7;
  --radius: 12px; --shadow: 0 1px 2px rgba(35,31,32,.06), 0 1px 3px rgba(35,31,32,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: Lato, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0 0 12px; color: var(--ink); font-weight: 900; } h2 { font-size: 18px; margin: 0 0 10px; color: var(--ink); font-weight: 700; } h3 { font-size: 15px; margin: 0 0 8px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--card); color: var(--ink); padding: env(safe-area-inset-top) 0 0; border-top: 4px solid var(--brand); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 12px; max-width: 1100px; margin: 0 auto; padding: 9px 16px; }
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand img { height: 34px; width: auto; max-width: 180px; object-fit: contain; display: block; }
.brand .app { color: var(--muted); font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; padding-left: 10px; border-left: 1px solid var(--line); }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a { color: var(--ink); padding: 7px 11px; border-radius: 8px; font-weight: 700; position: relative; }
.nav a.active { background: var(--brand-soft); color: var(--brand-dark); } .nav a:hover { background: #f4f4f6; }
.badge-dot { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 90px; }
.tabbar { display: none; }
@media (max-width: 720px) {
  .nav { display: none; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; font-size: 11px; color: var(--muted); position: relative; }
  .tabbar a.active { color: var(--brand); } .tabbar a.active svg { stroke: var(--brand); }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .badge-dot { top: 4px; right: calc(50% - 20px); }
}

/* Cards and lists */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .n { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.red .n { color: var(--red); } .stat.amber .n { color: var(--amber); } .stat.green .n { color: var(--green); }
.list { display: flex; flex-direction: column; gap: 8px; }
.task { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; color: inherit; border-left: 4px solid var(--line); }
.task:hover { box-shadow: 0 2px 8px rgba(16,24,40,.12); }
.task.p-high { border-left-color: var(--amber); } .task.p-urgent { border-left-color: var(--red); } .task.p-low { border-left-color: #b9babd; } .task.p-normal { border-left-color: #9a9ca0; }
.task.done { background: #fafafb; } .task.done .t { text-decoration: line-through; color: var(--muted); } .task.done .m { color: var(--muted); }
.task .body { flex: 1; min-width: 0; }
.task .t { font-weight: 700; margin-bottom: 2px; word-break: break-word; }
.task .m { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.task .m .overdue { color: var(--red); font-weight: 700; } .task .m .today { color: var(--amber); font-weight: 700; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--line); color: var(--ink); white-space: nowrap; border: 1px solid rgba(63,63,64,.12); }
.pill.open { background: #e6e7e8; color: var(--ink); } .pill.in_progress { background: var(--amber-soft); color: #92400e; }
.pill.done { background: var(--green-soft); color: #166534; } .pill.verified { background: var(--ink); color: #fff; }
.pill.urgent { background: var(--red-soft); color: #991b1b; } .pill.high { background: var(--amber-soft); color: #92400e; } .pill.low { background: #f4f4f6; color: #58595b; }
.pill.owner { background: var(--ink); color: #fff; } .pill.manager { background: var(--brand-soft); color: var(--brand-dark); } .pill.staff { background: #f4f4f6; color: var(--ink); }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

/* Forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 4px; color: var(--ink); }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.field textarea { min-height: 90px; resize: vertical; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.check input { width: 18px; height: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 8px; border: 1px solid transparent; background: var(--brand); color: #fff; font-weight: 700; cursor: pointer; }
.btn:hover { background: var(--brand-dark); } .btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border); } .btn.secondary:hover { background: #f4f4f6; }
.btn.danger { background: #fff; color: var(--red); border-color: var(--brand); } .btn.danger:hover { background: var(--red-soft); }
.btn.success { background: var(--green); } .btn.success:hover { background: #15803d; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.fab { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 15; width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 30px; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(199,34,45,.35); border: 0; cursor: pointer; }
@media (max-width: 720px) { .fab { bottom: calc(70px + env(safe-area-inset-bottom)); } }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; min-height: 40px; }
.toolbar input[type=search] { flex: 1; min-width: 140px; }
.tabs { display: flex; gap: 4px; background: #e6e7e8; padding: 4px; border-radius: 10px; margin-bottom: 12px; overflow-x: auto; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px 10px; border-radius: 8px; font-weight: 700; color: #58595b; cursor: pointer; white-space: nowrap; min-height: 40px; }
.tabs button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.auth { max-width: 420px; margin: 40px auto; }
.auth .logo { text-align: center; margin-bottom: 16px; } .auth .logo img { height: 64px; width: auto; max-width: 260px; }
.error { background: var(--red-soft); color: #991b1b; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.notice { background: var(--amber-soft); color: #92400e; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.info { background: #eef0f3; color: var(--ink); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 14px; } .kv b { color: var(--muted); font-weight: 700; }
.desc { white-space: pre-wrap; word-break: break-word; }
.checklist .item { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); min-height: 40px; }
.checklist .item input[type=checkbox] { width: 20px; height: 20px; flex: 0 0 20px; }
.checklist .item:last-child { border-bottom: 0; } .checklist .item.done span { text-decoration: line-through; color: var(--muted); }
.checklist .item span { flex: 1; } .checklist .item button { border: 0; background: none; color: var(--muted); cursor: pointer; min-width: 36px; min-height: 36px; border-radius: 8px; } .checklist .item button:hover { background: #f4f4f6; color: var(--brand); }
.comment { padding: 8px 0; border-bottom: 1px solid var(--line); } .comment:last-child { border-bottom: 0; }
.comment .who { font-weight: 700; font-size: 13px; } .comment .when { color: var(--muted); font-size: 12px; margin-left: 6px; }
.activity li { font-size: 13px; color: var(--muted); padding: 3px 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }
.notif { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); color: inherit; }
.notif.unread { background: #fdf6f6; margin: 0 -16px; padding: 10px 16px 10px 13px; border-left: 3px solid var(--brand); }
.notif .t { font-weight: 700; } .notif .b { color: var(--muted); font-size: 13px; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 6px; } .progress i { display: block; height: 100%; background: var(--green); }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 90vw; }
@media (max-width: 720px) { .toast { bottom: calc(80px + env(safe-area-inset-bottom)); } }
.toast.err { background: var(--red); }
details summary { cursor: pointer; font-weight: 700; color: var(--muted); }
.inline-form { display: flex; gap: 8px; } .inline-form input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.split { display: grid; gap: 14px; grid-template-columns: 2fr 1fr; } @media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.picker { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: #fff; }
.picker .check { margin: 4px 0; }
.brand img.logo { height: 34px; width: auto; max-width: 180px; object-fit: contain; }
.auth .logo img.logo { height: 72px; width: auto; max-width: 260px; object-fit: contain; }
.auth .appname { font-weight: 900; font-size: 15px; letter-spacing: .12em; text-transform: uppercase; margin-top: 12px; color: var(--brand); }

/* brand touches */
.stat .n { color: var(--ink); } .stat.red .n { color: var(--brand-dark); }
a { color: var(--brand-dark); }
::placeholder { color: var(--muted); opacity: 1; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .toolbar input:focus-visible, .toolbar select:focus-visible, .inline-form input:focus-visible, .btn:focus-visible, .fab:focus-visible, .tabs button:focus-visible, .nav a:focus-visible, .tabbar a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-color: var(--brand); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.btn { color: var(--on-brand); }
.task:hover { border-color: var(--line); }
.check input[type=checkbox], .checklist input[type=checkbox] { accent-color: var(--brand); }
