/* AutoWorkLab Plan — Dashboard UI */

:root {
  --navy: #1e293b;
  --navy-2: #0f172a;
  --accent: #3b82f6;
  --accent-soft: #eff6ff;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fff7ed;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --purple: #7c3aed;
  --purple-soft: #f5f3ff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
  --sidebar-w: 248px;
  --font: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { font-size: 15px; }

body.app-body,
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-2) 0%, var(--navy) 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.9rem 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-brand {
  padding: 0.35rem 0.75rem 1.25rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.sidebar-brand a {
  color: #fff;
  text-decoration: none;
}

.sidebar-nav {
  display: grid;
  gap: 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.95rem;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
  text-decoration: none;
}

.sidebar-link.is-active {
  background: var(--accent);
  color: #fff;
}

.sidebar-icon {
  width: 1.15rem;
  height: 1.15rem;
  display: inline-flex;
  flex-shrink: 0;
}

.sidebar-icon svg {
  width: 100%;
  height: 100%;
}

.sidebar-quick {
  margin-top: auto;
  padding: 1rem 0.55rem 0.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-quick-title {
  font-size: 0.75rem;
  color: #94a3b8;
  margin: 0 0 0.55rem 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-quick a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #cbd5e1;
  text-decoration: none;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  font-size: 0.88rem;
}

.sidebar-quick a:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  font-weight: 650;
  color: var(--text);
  margin-right: auto;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #1d4ed8;
  font-size: 0.82rem;
  text-decoration: none;
}

.topbar-chip:hover { text-decoration: none; filter: brightness(0.98); }

.topbar-user-name {
  font-size: 0.9rem;
  color: var(--muted);
  padding: 0 0.35rem;
}

.sidebar-toggle {
  display: none;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 0.45rem;
  cursor: pointer;
}

.sidebar-toggle span {
  display: block;
  height: 2px;
  background: var(--navy);
  margin: 0.28rem 0;
  border-radius: 2px;
}

.sidebar-backdrop {
  display: none;
}

.page {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2.5rem;
  flex: 1;
}

.site-footer {
  padding: 1rem 1.5rem 1.5rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.site-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
}

/* Typography / headers */
.page-header,
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.page-header h1,
.page-head h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.page-header .sub,
.page-head .sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.section-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 680;
}

.section-header a {
  font-size: 0.88rem;
}

.welcome {
  margin-bottom: 1.35rem;
}

.welcome h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.welcome p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

/* Cards */
.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.35rem;
}

.stat-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1rem 1.05rem;
  background: #fff;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.35rem;
  min-height: 118px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  text-decoration: none;
}

.stat-card .stat-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.7);
}

.stat-card .stat-icon svg {
  width: 1.1rem;
  height: 1.1rem;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-card .stat-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.stat-card .stat-link {
  font-size: 0.82rem;
  color: var(--accent);
  margin-top: auto;
}

.stat-blue { background: linear-gradient(180deg, #eff6ff, #fff); }
.stat-green { background: linear-gradient(180deg, #ecfdf5, #fff); }
.stat-orange { background: linear-gradient(180deg, #fff7ed, #fff); }
.stat-red { background: linear-gradient(180deg, #fef2f2, #fff); }
.stat-purple { background: linear-gradient(180deg, #f5f3ff, #fff); }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.dashboard-col {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.stack-gap {
  display: grid;
  gap: 1.25rem;
}

.empty,
.empty-state {
  padding: 1.6rem 1rem;
  text-align: center;
  color: var(--muted);
  background: #fafafa;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  padding: 0.52rem 0.95rem;
  border-radius: 9px;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { filter: brightness(0.96); text-decoration: none; }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.btn-danger { background: var(--danger); }
.btn-sm { padding: 0.28rem 0.6rem; font-size: 0.82rem; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.tabs,
.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.tab,
.filter-tabs a {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
}

.tab.is-active,
.filter-tabs a.is-active,
.tab:hover,
.filter-tabs a:hover {
  background: var(--accent-soft);
  border-color: #bfdbfe;
  color: #1d4ed8;
  text-decoration: none;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
  background: #f3f4f6;
  color: #4b5563;
}

.badge-active, .badge-doing { background: #dbeafe; color: #1d4ed8; }
.badge-hold { background: #ffedd5; color: #c2410c; }
.badge-done { background: #d1fae5; color: #047857; }
.badge-todo { background: #e5e7eb; color: #4b5563; }
.badge-high { background: #fee2e2; color: #b91c1c; }
.badge-normal { background: #ffedd5; color: #c2410c; }
.badge-low { background: #f3f4f6; color: #6b7280; }

/* Progress */
.progress {
  height: 8px;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
  margin: 0.35rem 0 0.1rem;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  border-radius: inherit;
}

/* Flash */
.flash {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  background: #fff;
}

.flash-ok { border-color: #a7f3d0; background: var(--ok-soft); color: #065f46; }
.flash-error { border-color: #fecaca; background: var(--danger-soft); color: #991b1b; }
.flash-info { border-color: #bfdbfe; background: var(--accent-soft); color: #1e40af; }

/* Forms */
.form-grid { display: grid; gap: 1rem; }
.form-grid.two { grid-template-columns: 1fr 1fr; }

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 0.62rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

textarea { min-height: 110px; resize: vertical; }

.field-label {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

/* Tables / rows */
table.data {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}

table.data th,
table.data td {
  padding: 0.7rem 0.35rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

table.data th {
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

table.data tr:last-child td { border-bottom: none; }

.task-row,
.list-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto auto auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.task-row:last-child,
.list-row:last-child { border-bottom: none; }

.task-row-done,
.task-row-done a {
  color: var(--muted);
}

.task-main {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.task-main a {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.task-main a:hover { color: var(--accent); }

.task-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.task-check {
  width: 1.1rem;
  height: 1.1rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 4px;
  display: inline-block;
  margin-right: 0.45rem;
  vertical-align: -0.15rem;
}

/* Project cards */
.project-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem;
  display: grid;
  gap: 0.75rem;
}

.project-card h2 {
  margin: 0;
  font-size: 1.05rem;
}

.project-card h2 a {
  color: var(--text);
  text-decoration: none;
}

.project-card h2 a:hover { color: var(--accent); }

.project-card-meta {
  display: grid;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.project-card-meta strong { color: var(--text); font-weight: 650; }

/* Week strip */
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(140px, 1fr));
  gap: 0.65rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.week-day {
  min-width: 140px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  min-height: 140px;
}

.week-day.is-today {
  border-color: #93c5fd;
  background: #f8fbff;
  box-shadow: inset 0 0 0 1px #bfdbfe;
}

.week-day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.55rem;
  font-size: 0.85rem;
}

.week-day-head .dow { color: var(--muted); }
.week-day-head .dow.is-sun { color: #dc2626; }
.week-day-head .date { font-weight: 700; }

.week-task {
  display: block;
  font-size: 0.8rem;
  color: var(--text);
  padding: 0.28rem 0;
  border-bottom: 1px dashed #eef2f7;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.week-task:last-child { border-bottom: none; }
.week-empty { font-size: 0.8rem; color: #9ca3af; }

/* Overdue / logs */
.schedule-overdue,
.alert-card {
  border-color: #fecaca;
  background: linear-gradient(180deg, #fff7f7, #fff);
}

.schedule-overdue h2,
.alert-card h2 { color: #991b1b; }

.overdue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.overdue-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
  font-size: 0.92rem;
}

.overdue-date {
  font-weight: 700;
  color: #b91c1c;
  min-width: 2.4rem;
}

.home-overdue {
  margin-bottom: 0.85rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: #fff7f7;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.88rem;
}

.timeline {
  display: grid;
  gap: 0.75rem;
}

.timeline-item {
  display: grid;
  grid-template-columns: 6.5rem 1fr auto;
  gap: 0.85rem;
  align-items: start;
  padding: 0.95rem 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.timeline-date {
  font-weight: 700;
  color: var(--navy);
  font-size: 0.92rem;
}

.timeline-body {
  min-width: 0;
}

.timeline-body .proj {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.timeline-body .preview {
  color: var(--text);
  font-size: 0.92rem;
}

.schedule-nav { align-items: center; margin-bottom: 1.1rem; }

.schedule-date-form {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.schedule-date-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.schedule-date-label input[type="date"] {
  width: auto;
  padding: 0.3rem 0.5rem;
}

.schedule-section-title {
  margin: 0 0 0.55rem;
  font-size: 0.92rem;
}

.schedule-section-done {
  margin-top: 1.1rem;
  color: var(--muted);
}

.schedule-day-title {
  margin: 0 0 0.75rem;
  font-size: 1.02rem;
}

.detail-grid { display: grid; gap: 0.55rem; margin-bottom: 0.5rem; }
.detail-grid dt { color: var(--muted); font-size: 0.82rem; }
.detail-grid dd { margin: 0 0 0.35rem; }

.muted { color: var(--muted); }

.check-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.95rem;
}

.check-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.field-hint {
  margin: 0;
  align-self: end;
  font-size: 0.85rem;
  color: var(--muted);
  padding-bottom: 0.35rem;
}

.field-hint-warn {
  color: #b45309;
}

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin: 0.25rem 0 0.75rem;
}

.pick-date-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.pick-date-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 28rem;
}

.pick-date-row input[type="date"] {
  flex: 1;
  min-width: 0;
}

.pick-actions {
  margin-bottom: 0.35rem;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Rich editor */
.rich-editor {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.rich-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 0.28rem 0.55rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.rich-btn:hover { background: var(--accent-soft); border-color: #bfdbfe; }

.rich-sep {
  width: 1px;
  height: 1.2rem;
  background: var(--border);
  margin: 0 0.15rem;
}

.rich-emoji-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  max-height: 140px;
  overflow-y: auto;
}

.rich-emoji-panel[hidden] { display: none !important; }

.rich-emoji {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  cursor: pointer;
}

.rich-emoji:hover { background: var(--bg); }

.rich-surface {
  min-height: 280px;
  max-height: 560px;
  overflow-y: auto;
  padding: 0.85rem 1rem;
  line-height: 1.65;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.rich-surface:empty::before,
.rich-surface.is-empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
}

.rich-surface ul,
.rich-surface ol { margin: 0.4rem 0 0.4rem 1.25rem; padding: 0; }
.rich-surface p { margin: 0 0 0.6rem; }
.rich-hidden { display: none !important; }

.log-preview { color: var(--text); font-size: 0.92rem; }
a.log-preview-link { color: var(--text); text-decoration: none; }
a.log-preview-link:hover { color: var(--accent); text-decoration: underline; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at top right, #dbeafe 0%, transparent 40%),
    radial-gradient(circle at bottom left, #e0e7ff 0%, transparent 35%),
    var(--bg);
}

.login-box {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem;
}

.login-box h1 { margin: 0 0 0.3rem; font-size: 1.45rem; }
.login-box .sub { margin: 0 0 1.4rem; color: var(--muted); }

.login-error {
  margin-bottom: 1rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--danger-soft);
  color: #991b1b;
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }

  body.sidebar-open .sidebar { transform: translateX(0); }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 30;
  }

  .sidebar-backdrop[hidden] { display: none; }

  .sidebar-toggle { display: inline-block; }

  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-grid.two { grid-template-columns: 1fr; }
  .timeline-item { grid-template-columns: 1fr; }
  .task-row { grid-template-columns: 1fr; gap: 0.35rem; }
  .topbar-actions .btn-ghost { display: none; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
  .page { padding: 1rem 1rem 2rem; }
  .app-topbar { padding: 0.7rem 1rem; }
}
