:root {
  color-scheme: light dark;
  --bg: #f5f7ff;
  --bg2: #ffffff;
  --text: #12151f;
  --muted: #5f6780;
  --border: #d7ddf0;
  --accent: linear-gradient(135deg, #4f46e5, #06b6d4);
  --danger: #c02626;
  --input-bg: #ffffffcc;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d111c;
    --bg2: #131a2a;
    --text: #ecf0ff;
    --muted: #97a3c5;
    --border: #2b3451;
    --input-bg: #131a2ae0;
  }
}

:root[data-theme="light"] {
  --bg: #f5f7ff;
  --bg2: #ffffff;
  --text: #12151f;
  --muted: #5f6780;
  --border: #d7ddf0;
  --input-bg: #ffffffcc;
}

:root[data-theme="dark"] {
  --bg: #0d111c;
  --bg2: #131a2a;
  --text: #ecf0ff;
  --muted: #97a3c5;
  --border: #2b3451;
  --input-bg: #131a2ae0;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif;
  color: var(--text);
  font-weight: 550;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at top, #6d7dff33, transparent 46%),
    radial-gradient(circle at 85% 25%, #06b6d422, transparent 40%),
    linear-gradient(165deg, color-mix(in srgb, var(--bg) 86%, #120c2a 14%), var(--bg));
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
}

a { color: inherit; }

.container { width: min(1100px, 94vw); margin: 2rem auto; }
.auth-layout {
  min-height: calc(100vh - 4rem);
  display: flex;
  justify-content: center;
  align-items: center;
}

.auth-shell {
  width: min(460px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.auth-title {
  width: 100%;
  text-align: center;
  margin: 0;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.auth-card {
  width: min(420px, 100%);
  margin-bottom: 0;
}

.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.stacked-form { display: flex; flex-direction: column; gap: 0.75rem; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] { width: auto; }

h1,h2,h3 { margin: 0.2rem 0 0.7rem; }
small, .muted { color: var(--muted); font-weight: 550; }

.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;
}

input, select, button {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.6rem 0.7rem;
  background: var(--input-bg);
  color: var(--text);
  min-height: 42px;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 13px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

button {
  background: var(--accent);
  border: 0;
  color: #fff;
  cursor: pointer;
}
button.danger { background: var(--danger); }

input:disabled, select:disabled {
  opacity: 1;
  color: var(--text);
  background: color-mix(in srgb, var(--bg2) 78%, var(--border) 22%);
}

.flash { padding: 0.6rem 0.8rem; border-radius: 10px; margin-bottom: 0.6rem; }
.auth-shell .flash {
  width: 100%;
  margin-bottom: 0;
}
.flash.error { background: #b91c1c22; border: 1px solid #b91c1c66; }
.flash.success { background: #16a34a22; border: 1px solid #16a34a66; }

.timer-composer { max-width: 860px; display: flex; flex-direction: column; gap: 0.6rem; }
.timer-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
}
.timer-elapsed-inline {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  white-space: nowrap;
}
.timer-row button { min-width: 110px; }
.timer-row-running {
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto auto;
}

.combobox { position: relative; }
.combobox input { width: 100%; }
.combobox-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg2);
  max-height: 230px;
  overflow: auto;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.3rem);
  z-index: 20;
}

.combobox-list [role="option"] {
  border-radius: 9px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.combobox-list [role="option"][aria-selected="true"],
.combobox-list [role="option"]:hover {
  background: color-mix(in srgb, #4f46e5 26%, var(--bg2));
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border); text-align: left; padding: 0.4rem 0.35rem; }

.entries-table th { font-weight: 620; }
.entries-table td { font-weight: 430; }

.entries-table td, .entries-table th { white-space: nowrap; }
.entry-label-cell { max-width: 340px; }
.entry-label-text {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.entry-edit-toggle {
  min-height: 34px;
  padding: 0.35rem 0.65rem;
}

.entry-detail-row td {
  padding-top: 0.55rem;
  padding-bottom: 0.6rem;
}

.entry-detail-wrap {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.entry-detail-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.entry-delete-form {
  margin: 0;
}

.manual-entry-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(160px, 1fr) minmax(160px, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
}

.settings-manage-card { margin-top: 0.8rem; }

svg { width: 100%; height: auto; }

@media (max-width: 900px) {
  .timer-row,
  .timer-row-running,
  .manual-entry-row {
    grid-template-columns: 1fr;
  }

  .timer-row button,
  .timer-row-running button,
  .manual-entry-row button {
    width: 100%;
  }

  .entries-table td,
  .entries-table th { white-space: normal; }
}

@media (max-width: 720px) {
  .container { width: 96vw; }
}
