* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  background: #0f1115;
  color: #e6e8ef;
}

/* High-contrast link styling (avoid blue/purple visited state). */
a, a:visited {
  color: #f3f4f6;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}
a:hover, a:focus-visible {
  color: #ffffff;
  background: #1f2937;
  outline: 2px solid #9ca3af;
  outline-offset: 1px;
  border-radius: 4px;
}

.topbar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid #2b3040;
  background: #151924;
}
.topbar-left{display:flex; align-items:center; gap:10px}
.topbar-right{display:flex; align-items:center}
.topbar .brand { font-weight: 700; }
.topbar a { margin-left: 0; }
.nav-back-btn{
  padding:6px 10px;
  min-width:74px;
  font-size:13px;
  line-height:1;
}
.menu-btn{
  width:34px; height:34px; padding:0;
  border-radius:8px; border:1px solid var(--app-border);
  background:var(--app-input); color:var(--app-text); font-size:18px; line-height:1;
}
.main-nav{
  position:absolute; left:12px; top:56px; z-index:20;
  min-width:240px; display:none; flex-direction:column; gap:2px;
  background:var(--app-panel2); border:1px solid var(--app-border); border-radius:10px; padding:8px;
  box-shadow:0 10px 24px rgba(0,0,0,.35);
}
.main-nav.open{display:flex}
.main-nav a{display:block; padding:8px 10px; border-radius:6px; text-decoration:none; color:var(--app-text)}
.main-nav a:hover{background:color-mix(in srgb, var(--app-panel2) 70%, var(--app-border))}
.logout-link{white-space:nowrap}
.container { padding: 16px; }
.card {
  background: #171c28;
  border: 1px solid #2c3448;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.add-form { display: grid; grid-template-columns: 2fr 2fr 120px 130px 140px 110px; gap: 10px; }
.task-edit-form{grid-template-columns:repeat(4,minmax(180px,1fr)); align-items:center}
.task-edit-form button{width:100%}
.task-edit-form .assignee-dd{min-width:0}
input, select, button {
  border-radius: 8px;
  border: 1px solid #33405d;
  padding: 9px 10px;
  background: #0f1420;
  color: #e6e8ef;
}

/* Global select/dropdown system: consistent, high-contrast control style */
select {
  background: #1e3a8a;
  color: #ffffff;
  border: 1px solid #1d4ed8;
  font-weight: 700;
}
select:hover {
  background: #1e40af;
  border-color: #1e40af;
}
select:focus-visible,
select:focus {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}
select option {
  background: #0f172a;
  color: #ffffff;
}

/* Global button system: consistent, high-contrast CTA style */
button,
input[type="button"],
input[type="submit"],
input[type="reset"] {
  background: #2563eb;
  color: #ffffff;
  border: 1px solid #1d4ed8;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, 0 2px 8px rgba(37,99,235,0.35);
}
button:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
input[type="reset"]:hover {
  background: #1d4ed8;
  border-color: #1e40af;
}
button:focus-visible,
input[type="button"]:focus-visible,
input[type="submit"]:focus-visible,
input[type="reset"]:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}
.assignee-dd { position: relative; }
.assignee-dd summary {
  list-style: none;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--app-border);
  padding: 9px 10px;
  background: var(--app-input);
  color: var(--app-text);
}
.assignee-dd summary::-webkit-details-marker { display:none; }
.assignee-dd-menu {
  position: absolute;
  z-index: 30;
  margin-top: 4px;
  min-width: 220px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 8px;
  background: var(--app-input);
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
}
.assignee-dd-menu label { display:flex !important; flex-direction:row !important; align-items:center !important; gap:8px; padding: 5px 2px; cursor:pointer; white-space:nowrap; }
.assignee-dd-menu label input[type="checkbox"]{ width:auto !important; height:auto !important; margin:0 !important; padding:0 !important; flex:0 0 auto; vertical-align:middle; }
input[type="date"] { cursor: pointer; }
button { cursor: pointer; }
button.secondary { background: #2563eb; border-color: #1d4ed8; }
.error { color: #ff8f8f; }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 980px; margin: 30px auto; }
.auth-grid form { display: grid; gap: 8px; }
.projects-board { display: grid; gap: 12px; }
.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.column {
  background: #111521;
  border: 1px solid #2a3246;
  border-radius: 12px;
  padding: 10px;
  min-height: 520px;
}
.status-section {
  margin: 0 10px 10px;
  padding: 8px;
  border: 1px dashed #2f3952;
  border-radius: 10px;
  background: #101726;
}
.status-section h4 {
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.column-head { display:flex; justify-content:space-between; align-items:center; gap:8px; margin: 4px 4px 10px; }
.column h3 { margin: 0; }
.col-controls { display:flex; gap:6px; }
.col-controls button { padding: 5px 8px; font-size: 12px; }
.overdue-badge { background:#8a2e2e; }
.job-group {
  border: 1px solid var(--app-border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: var(--app-panel2);
}
.job-group summary {
  list-style: none;
  cursor: pointer;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}
.job-group summary::-webkit-details-marker { display: none; }
.co-summary{cursor:pointer; padding:12px 10px; border-radius:8px; background:color-mix(in srgb, var(--app-panel2) 82%, var(--app-border));}
.co-summary:hover{filter:brightness(1.05)}
.co-summary::-webkit-details-marker{display:none}

.budget-section-header{
  cursor:pointer;
  user-select:none;
  padding:10px 12px;
  border-radius:8px;
  border:1px solid rgba(96,165,250,.45);
  background:linear-gradient(180deg, rgba(37,99,235,.28), rgba(30,64,175,.18));
  color:#eef4ff;
  font-weight:700;
  letter-spacing:.2px;
}
.budget-section-header:hover{filter:brightness(1.06)}

.budget-area{
  border:1px solid rgba(148,163,184,.28);
  border-radius:10px;
  padding:10px;
  margin-top:10px;
  background:rgba(15,23,42,.22);
}
.budget-divider{
  height:1px;
  border:0;
  margin:12px 0;
  background:linear-gradient(90deg, rgba(148,163,184,.15), rgba(96,165,250,.55), rgba(148,163,184,.15));
}
.co-details .meta{color:var(--app-text)!important}
.collapsible-block summary{display:flex; justify-content:space-between; align-items:center; cursor:pointer; list-style:none}
.collapsible-block summary::-webkit-details-marker{display:none}
.collapsible-block[open] summary .meta{opacity:.85}

:root{
  --app-bg:#0f1220;
  --app-text:#e6e8ef;
  --app-panel:#151a2b;
  --app-panel2:#1b2238;
  --app-border:#2c3448;
  --app-input:#0f1420;
  --app-muted:#a8b4cc;
}
html[data-theme="dark"]{
  --app-bg:#0a0a0b;
  --app-text:#f2f2f3;
  --app-panel:#151517;
  --app-panel2:#1d1e21;
  --app-border:#3b3d44;
  --app-input:#111214;
  --app-muted:#c4c7cf;
}
html[data-theme="dark"] a,
html[data-theme="dark"] a:visited{color:#f2f2f3}
html[data-theme="dark"] a:hover,
html[data-theme="dark"] a:focus-visible{color:#ffffff; background:#2a2c31; outline-color:#8d919a}
html[data-theme="dark"] .kpi,
html[data-theme="dark"] .kpi .kpi-label,
html[data-theme="dark"] .kpi .kpi-val,
html[data-theme="dark"] .kpi a{color:#fff !important}
html[data-theme="dark"] .gauge::before{background:#0f1012; border-color:#3b3d44}
html[data-theme="dark"] .gauge span{color:#f2f2f3}

/* Morning Review should always be high-contrast white regardless theme */
.morning-review-surface,
.morning-review-surface .card,
.morning-review-surface .panel,
.morning-review-surface .task,
.morning-review-surface table,
.morning-review-surface tr,
.morning-review-surface td,
.morning-review-surface th{
  background:#ffffff !important;
  color:#111827 !important;
  border-color:#d2d8e3 !important;
}
.morning-review-surface .meta,
.morning-review-surface a,
.morning-review-surface a:visited{color:#1f2a3d !important}
.morning-review-surface .badge{background:#334b74 !important; color:#fff !important}
.morning-review-surface button,
.morning-review-surface .btn,
.morning-review-surface a,
.morning-review-surface a:link,
.morning-review-surface a:visited,
.morning-review-surface a:active,
.morning-review-surface a.btn,
.morning-review-surface a.button{
  background:#1f3b67 !important;
  color:#ffffff !important;
  -webkit-text-fill-color:#ffffff !important;
  border-color:#1b355c !important;
  text-decoration:none !important;
  opacity:1 !important;
}
.morning-review-surface button:hover,
.morning-review-surface .btn:hover,
.morning-review-surface a:hover,
.morning-review-surface a.btn:hover,
.morning-review-surface a.button:hover{
  background:#27497d !important;
  color:#ffffff !important;
  -webkit-text-fill-color:#ffffff !important;
}
html[data-theme="light"]{
  --app-bg:#f4f7fb;
  --app-text:#1c2433;
  --app-panel:#ffffff;
  --app-panel2:#eef3fb;
  --app-border:#c9d6ea;
  --app-input:#ffffff;
  --app-muted:#44556f;
}
html[data-theme="light"] .kpi,
html[data-theme="light"] .kpi .kpi-label,
html[data-theme="light"] .kpi .kpi-val,
html[data-theme="light"] .kpi a{color:#fff !important}
html[data-theme="light"] a,
html[data-theme="light"] a:visited{color:#1c2433}
html[data-theme="light"] a:hover,
html[data-theme="light"] a:focus-visible{color:#111827; background:#dbe6f7; outline-color:#7f93b3}
html[data-theme="light"] .dash-side a,
html[data-theme="light"] .dash-side a:visited{color:#1c2433 !important; text-decoration-color:#7f93b3 !important; opacity:1 !important}
html[data-theme="light"] .dash-side a:hover{background:#dbe6f7}
html[data-theme="light"] .dash-side .new-assign-badge{color:#111 !important; text-decoration:none !important}
html[data-theme="light"] .dash-side .badge{background:#42557d !important; color:#fff !important}
html[data-theme="light"] .task{background:#ffffff; border-color:#c9d6ea; color:#1c2433}
html[data-theme="light"] .gauge::before{background:#ffffff; border-color:#c9d6ea}
html[data-theme="light"] .gauge span{color:#1c2433}
html[data-theme="ocean"]{
  --app-bg:#0b1a24;
  --app-text:#d8f1ff;
  --app-panel:#102634;
  --app-panel2:#153145;
  --app-border:#2c5a73;
  --app-input:#0f2432;
}
html[data-theme="crimson"]{
  --app-bg:#1f0b0d;
  --app-text:#ffe9e9;
  --app-panel:#311014;
  --app-panel2:#45161b;
  --app-border:#8a2a33;
  --app-input:#2a0f13;
  --app-muted:#d9aeb2;
}
body{background:var(--app-bg)!important; color:var(--app-text)!important}
.topbar,.card,.panel{background:var(--app-panel)!important; border-color:var(--app-border)!important}
section.card.add-card,.group-box,.subgroup-box,.filter-panel,.add-panel{background:var(--app-panel2)!important; border-color:var(--app-border)!important}
input,select,button,textarea{background:var(--app-input)!important; color:var(--app-text)!important; border-color:var(--app-border)!important}

/* Final UI overrides (must be after theme !important base rule) */
button,
input[type="button"],
input[type="submit"],
input[type="reset"] {
  background:#2563eb !important;
  color:#ffffff !important;
  border-color:#1d4ed8 !important;
  font-weight:700;
  box-shadow:0 1px 0 rgba(255,255,255,0.10) inset, 0 0 14px rgba(37,99,235,0.45) !important;
}
button:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
input[type="reset"]:hover {
  background:#1d4ed8 !important;
  border-color:#1e40af !important;
}

select {
  background:#0b1220 !important;
  color:#ffffff !important;
  border:1px solid #2563eb !important;
  box-shadow:0 0 0 1px rgba(37,99,235,0.35), 0 0 10px rgba(37,99,235,0.25) !important;
  font-weight:700;
}
select:hover { border-color:#3b82f6 !important; }
select:focus,
select:focus-visible {
  outline:2px solid #93c5fd !important;
  outline-offset:2px;
}
select option {
  background:#0f172a !important;
  color:#ffffff !important;
}

.field-label{display:grid; gap:4px; font-size:11px; color:var(--app-muted)}
.meta{color:var(--app-muted)!important}
.task-action-btn{background:#2b5fb3 !important; color:#fff !important; border-color:#254f94 !important; font-weight:700}
.task-action-btn:hover{background:#3570cc !important}
.jt-add-btn{width:auto !important; min-width:96px; max-width:120px; justify-self:start;}
html[data-theme="light"] .task-action-btn{background:#2b5fb3 !important; color:#fff !important}
html[data-theme="crimson"] .task-action-btn{background:#a53a3a !important; border-color:#8e2f2f !important}

.task {
  border: 1px solid #333f5c;
  border-radius: 10px;
  padding: 10px;
  margin: 0 10px 10px;
  background: #1a2233;
}
.task-head { display: flex; justify-content: space-between; gap: 8px; }
.badge {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: #30384f;
}
.p-high { border-left: 4px solid #e05656; }
.p-med { border-left: 4px solid #d5a431; }
.p-low { border-left: 4px solid #48b36a; }
.meta { color: #a8b4cc; font-size: 12px; }
.ui-tip{color:#facc15 !important; font-weight:700; font-size:12px;}
.actions { display: flex; gap: 8px; align-items: center; }
.actions form { display: inline-flex; gap: 6px; }
/* Dashboard */
.dash-wrap { display: grid; grid-template-columns: 230px 1fr; gap: 14px; }
.dash-side { min-height: 680px; }
.dash-side h2 { margin-top: 0; }
.dash-side a { display: block; padding: 10px; border-radius: 8px; margin-bottom: 6px; }
.dash-side a:hover { background: #26314b; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi-grid-rich { grid-template-columns: repeat(6, 1fr); }
.kpi { border: 1px solid #38425e; border-radius: 12px; padding: 12px; }
.kpi-label { color: #b8c8e9; font-size: 12px; }
.kpi-val { font-size: 30px; font-weight: 800; }
.kpi-open { background: linear-gradient(135deg,#17407a,#2f7fe5); }
.kpi-overdue { background: linear-gradient(135deg,#7a1d32,#cc3f5f); }
.kpi-today { background: linear-gradient(135deg,#256568,#2fb5bb); }
.kpi-waiting { background: linear-gradient(135deg,#584083,#8c6bd7); }
.gauge-grid { display:grid; grid-template-columns: repeat(4, 1fr); gap:12px; margin-bottom:12px; }
.gauge-card { text-align:center; }
.gauge {
  --val: 0;
  --gcolor: #2eb872;
  width: 150px;
  height: 150px;
  margin: 8px auto 4px;
  border-radius: 50%;
  background: conic-gradient(var(--gcolor) calc(var(--val) * 1%), #2a3246 0);
  position: relative;
}
.gauge::before {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  background: #111827;
  border: 1px solid #33405d;
}
.gauge span {
  position: absolute;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 28px;
  font-weight: 800;
  z-index: 2;
}
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.panel h3 { margin-top: 0; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(150px, 220px) 1fr 40px; align-items: center; gap: 10px; }
.bar-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #111827; border: 1px solid #2c3448; border-radius: 999px; overflow: hidden; height: 14px; }
.bar-fill { height: 100%; background: linear-gradient(90deg,#42d6ff,#7f8cff); }
.bar-fill.pri-high { background: linear-gradient(90deg,#ff6b6b,#ff3d6e); }
.bar-fill.pri-med { background: linear-gradient(90deg,#ffc857,#f59f00); }
.bar-fill.pri-low { background: linear-gradient(90deg,#67d98f,#2eb872); }
.overdue-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.overdue-list li { border: 1px solid #353f58; border-radius: 10px; padding: 10px; background: #1a2233; display: grid; }
.overdue-list span { color: #a8b4cc; font-size: 12px; }
.new-assign-badge{display:inline-block; padding:1px 6px; border-radius:999px; background:#ffcc00 !important; color:#111 !important; font-weight:800; font-size:10px; animation:pulse-new 1.4s infinite; text-decoration:none !important}
.dash-side a .new-assign-badge{margin-left:8px}
@keyframes pulse-new{0%{box-shadow:0 0 0 0 rgba(255,204,0,.7)}70%{box-shadow:0 0 0 8px rgba(255,204,0,0)}100%{box-shadow:0 0 0 0 rgba(255,204,0,0)}}

@media (max-width: 1200px) {
  .board { grid-template-columns: 1fr 1fr; }
  .add-form { grid-template-columns: 1fr 1fr; }
  .dash-wrap { grid-template-columns: 1fr; }
  .kpi-grid, .kpi-grid-rich { grid-template-columns: 1fr 1fr; }
  .gauge-grid { grid-template-columns: 1fr 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
}

/* AI HELP bubble + panel (read-only assistant) */
.ai-help-bubble{
  position:fixed !important;
  right:18px !important;
  bottom:18px !important;
  z-index:60 !important;
  width:64px !important;
  height:64px !important;
  min-width:64px !important;
  min-height:64px !important;
  padding:0 !important;
  border-radius:999px !important;
  border:1px solid #991b1b !important;
  background:linear-gradient(180deg,#ef4444,#b91c1c) !important;
  color:#fff !important;
  font-weight:800 !important;
  letter-spacing:.4px;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  box-shadow:0 10px 24px rgba(127,29,29,.45) !important;
}
.ai-help-bubble:hover{filter:brightness(1.08)}

.ai-help-panel{
  position:fixed;
  right:18px;
  bottom:92px;
  z-index:61;
  width:min(460px, calc(100vw - 24px));
  max-height:min(72vh, 640px);
  overflow:auto;
  display:none;
  border:1px solid #2c3448;
  border-radius:12px;
  padding:12px;
  background:#0f172a;
  box-shadow:0 16px 40px rgba(0,0,0,.45);
}
.ai-help-panel.open{display:block}
.ai-help-head{display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:8px}
.ai-help-close{width:34px; height:34px; border-radius:8px; padding:0}
.ai-help-form{display:grid; grid-template-columns:1fr auto; gap:8px}
.ai-help-form input{min-width:0}
.ai-help-suggestions{display:flex; flex-wrap:wrap; gap:6px; margin-top:10px}
.ai-help-chip{
  text-decoration:none;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid #334155;
  background:#111827;
  color:#fff;
  font-size:12px;
}
.ai-help-results{display:grid; gap:8px; margin-top:10px}
.ai-help-row{
  display:grid;
  gap:3px;
  text-decoration:none;
  border:1px solid #2c3448;
  border-radius:8px;
  padding:8px;
  background:#0b1220;
}
.ai-help-row span{font-size:12px; color:#b8c2d9}
