@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('assets/inter-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('assets/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --color-surface: #ffffff;
  --color-background: #f5f5f5;
  --color-text: #1e1e1e;
  --color-muted: #666666;
  --color-border: #d9d9d9;
  --color-primary: #2c2c2c;
  --color-primary-hover: #404040;
  --color-doing-bg: #eff6ff;
  --color-doing-text: #1d4ed8;
  --color-done-bg: #ecfdf3;
  --color-done-text: #166534;
  --color-todo-bg: #f1f5f9;
  --color-todo-text: #334155;
  --color-danger: #900b09;
  --color-danger-bg: #fef2f2;
  --color-warning-bg: #fffbeb;
  --color-warning-text: #92400e;
  --radius-8: 8px;
  --space-4: 4px;
  --space-8: 8px;
  --space-12: 12px;
  --space-16: 16px;
  --space-20: 20px;
  --space-24: 24px;
  --space-32: 32px;
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 24px;
  color: var(--color-text);
  background-color: var(--color-surface);
  min-height: 100vh;
  word-break: break-word;
}
#app { min-height: 100vh; display: flex; flex-direction: column; }

h2, h3 { font-size: 20px; font-weight: 600; line-height: 28px; color: var(--color-text); }

.skip-link {
  position: absolute; top: -9999px; left: var(--space-16);
  padding: 8px var(--space-16); background: var(--color-primary); color: #ffffff;
  border-radius: var(--radius-8); font-weight: 600; text-decoration: none; z-index: 1000;
}
.skip-link:focus, .skip-link:focus-visible { top: var(--space-16); outline: 2px solid var(--color-primary); outline-offset: 2px; }

.demo-banner {
  background-color: var(--color-warning-bg); color: var(--color-warning-text);
  border-bottom: 1px solid #fef3c7; padding: 8px var(--space-16);
  text-align: center; font-size: 13px; font-weight: 500; line-height: 20px;
}

.app-header {
  min-height: 64px; background-color: var(--color-surface); border-bottom: 1px solid var(--color-border);
  padding: 0 var(--space-24); display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-16); flex-shrink: 0;
}
.app-header h1, .app-header .brand { font-size: 18px; font-weight: 600; line-height: 24px; color: var(--color-text); text-decoration: none; }
.app-header .actions { display: flex; align-items: center; gap: var(--space-12); flex-wrap: wrap; }
.app-header .user-name {
  font-size: 14px; font-weight: 500; color: var(--color-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px;
}
.app-header .header-link {
  font-size: 14px; font-weight: 500; color: var(--color-muted); text-decoration: none;
  padding: 8px var(--space-8); border-radius: var(--radius-8); min-height: 44px;
  display: inline-flex; align-items: center;
}
.app-header .header-link:hover { color: var(--color-text); text-decoration: underline; }
.app-header .header-link:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.app-shell { display: flex; flex: 1 1 auto; min-height: 0; width: 100%; }
.sidebar {
  width: 200px; background-color: var(--color-background); border-right: 1px solid var(--color-border);
  padding: var(--space-24) var(--space-12); display: flex; flex-direction: column; gap: var(--space-8); flex-shrink: 0;
}
.sidebar-nav { display: flex; flex-direction: column; gap: var(--space-4); width: 100%; }
.sidebar .nav-link {
  display: flex; align-items: center; min-height: 44px; padding: 0 var(--space-12);
  border-radius: var(--radius-8); color: var(--color-text); text-decoration: none;
  font-size: 14px; font-weight: 500;
}
.sidebar .nav-link:hover { background-color: #ebebeb; }
.sidebar .nav-link:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.sidebar .nav-link.is-current, .sidebar .nav-link[aria-current="page"] {
  background-color: #e5e5e5; font-weight: 600; color: var(--color-text);
}

.main {
  flex: 1; min-width: 0; background-color: var(--color-surface);
  padding: var(--space-32); display: flex; flex-direction: column; gap: var(--space-24);
  max-width: 1200px; width: 100%;
}
.main-col { display: flex; flex-direction: column; gap: var(--space-16); min-width: 0; }

.auth-shell {
  min-height: 100vh; background-color: var(--color-background);
  display: flex; align-items: center; justify-content: center; padding: var(--space-24);
}
.auth-card {
  width: 100%; max-width: 400px; background-color: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-8);
  padding: var(--space-32); display: flex; flex-direction: column; gap: var(--space-20);
}
.auth-brand { font-size: 14px; font-weight: 600; color: var(--color-muted); }
.auth-intro { display: flex; flex-direction: column; gap: var(--space-4); }
.auth-card h1, .auth-intro h1 { font-size: 24px; font-weight: 600; line-height: 32px; color: var(--color-text); }
.auth-intro p, .auth-intro .subtitle { font-size: 14px; line-height: 20px; color: var(--color-muted); }
.auth-card .language-picker { align-self: flex-end; }

.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-16); flex-wrap: wrap; }
.page-heading h1 { font-size: 24px; font-weight: 600; line-height: 32px; color: var(--color-text); }
.page-heading p, .page-heading .subtitle { font-size: 14px; line-height: 24px; color: var(--color-muted); }

.breadcrumbs, .breadcrumb { display: flex; gap: var(--space-8); font-size: 14px; line-height: 24px; color: var(--color-muted); }
.breadcrumbs a, .breadcrumb a { color: var(--color-muted); text-decoration: none; }
.breadcrumbs a:hover, .breadcrumb a:hover { text-decoration: underline; color: var(--color-text); }

.actions { display: flex; align-items: center; gap: var(--space-12); flex-wrap: wrap; }
.tabs { display: flex; align-items: center; gap: var(--space-8); border-bottom: 1px solid var(--color-border); padding-bottom: var(--space-12); }
.stats { display: flex; flex-wrap: wrap; gap: var(--space-16) var(--space-32); font-size: 14px; line-height: 24px; color: var(--color-text); }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-12); width: 100%; }
.filters.form-row > .field { flex: 1; min-width: 150px; }
.filters .field:has(input[name="q"]) { flex: 2; min-width: 200px; }
.filters .button, .filters button { flex: 0 0 auto; height: 44px; align-self: flex-end; }

.form { display: flex; flex-direction: column; gap: var(--space-16); width: 100%; }
.form[data-form="task"], .task-form, .form[data-form="project"], .project-form { max-width: 720px; }
.form-row { display: flex; gap: var(--space-16); width: 100%; }
.form-row > .field, .form-row > fieldset { flex: 1; min-width: 0; }
.form-row > .button, .form-row > button, .form-row > a { flex: 0 0 auto; align-self: flex-end; height: 44px; }

.field { display: flex; flex-direction: column; gap: var(--space-4); width: 100%; }
.field label { font-size: 14px; font-weight: 500; line-height: 20px; color: var(--color-text); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 8px var(--space-12); font-family: inherit;
  font-size: 16px; line-height: 24px; color: var(--color-text); background-color: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-8);
}
.field textarea { min-height: 100px; resize: vertical; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
  outline: 2px solid var(--color-primary); outline-offset: 2px; border-color: var(--color-primary);
}
.field input[aria-invalid="true"], .field select[aria-invalid="true"], .field textarea[aria-invalid="true"],
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--color-danger); }
.field-error { font-size: 13px; line-height: 20px; color: var(--color-danger); }
#settings-username[readonly], .field input[readonly] {
  background-color: var(--color-background); color: var(--color-text);
  border-color: var(--color-border); cursor: default;
}

.button, button, input[type="submit"], input[type="button"] {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; min-width: 44px; padding: 0 var(--space-16); font-family: inherit;
  font-size: 16px; font-weight: 500; line-height: 24px; border-radius: var(--radius-8);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background-color: var(--color-background); color: var(--color-text);
}
.button:focus-visible, button:focus-visible, input[type="submit"]:focus-visible,
input[type="button"]:focus-visible, a:focus-visible {
  outline: 2px solid var(--color-primary); outline-offset: 2px;
}
.button:disabled, button:disabled { opacity: 0.5; cursor: not-allowed; }

.button.primary, button.primary, .primary { background-color: var(--color-primary); color: #ffffff; border-color: var(--color-primary); }
.button.primary:hover:not(:disabled), button.primary:hover:not(:disabled) { background-color: var(--color-primary-hover); border-color: var(--color-primary-hover); }

.button.secondary, button.secondary, .secondary { background-color: var(--color-background); color: var(--color-text); border-color: var(--color-border); }
.button.secondary:hover:not(:disabled), button.secondary:hover:not(:disabled) { background-color: #e5e5e5; }

.button.subtle, button.subtle, .subtle { background-color: transparent; color: var(--color-text); border-color: transparent; }
.button.subtle:hover:not(:disabled), button.subtle:hover:not(:disabled) { background-color: var(--color-background); }

.button.danger, button.danger, .danger { background-color: var(--color-danger); color: #ffffff; border-color: var(--color-danger); }
.button.danger:hover:not(:disabled), button.danger:hover:not(:disabled) { background-color: #730907; border-color: #730907; }

.badge {
  display: inline-flex; align-items: center; height: 32px; padding: 0 var(--space-12);
  border-radius: var(--radius-8); font-size: 14px; line-height: 24px; white-space: nowrap;
}
.badge.todo, .todo { background-color: var(--color-todo-bg); color: var(--color-todo-text); }
.badge.doing, .doing { background-color: var(--color-doing-bg); color: var(--color-doing-text); }
.badge.done, .done { background-color: var(--color-done-bg); color: var(--color-done-text); }
.badge.overdue, .overdue { color: var(--color-danger); }

.table-wrap { width: 100%; overflow-x: auto; }
.task-table, .project-table, .member-table {
  width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; line-height: 24px;
}
.task-table th, .project-table th, .member-table th {
  background-color: var(--color-background); font-weight: 600; color: var(--color-text);
  padding: var(--space-12); border-bottom: 1px solid var(--color-border);
}
.task-table td, .project-table td, .member-table td {
  padding: var(--space-12); border-bottom: 1px solid var(--color-border); vertical-align: middle;
}
.task-table a, .project-table a, .member-table a { color: var(--color-text); text-decoration: none; }
.task-table a:hover, .project-table a:hover, .member-table a:hover { text-decoration: underline; }

.detail-grid { display: grid; grid-template-columns: 1fr 354px; gap: var(--space-32); width: 100%; align-items: start; }
.metadata {
  background-color: var(--color-background); border-radius: var(--radius-8);
  padding: var(--space-16); display: flex; flex-direction: column; gap: var(--space-16);
}
.metadata h2, .metadata h3 { font-size: 20px; font-weight: 600; line-height: 28px; color: var(--color-text); }

.description { white-space: pre-wrap; word-break: break-word; }
.comments-list, .history-list { display: flex; flex-direction: column; gap: var(--space-12); }
.comment {
  display: flex; flex-direction: column; gap: var(--space-8); padding: var(--space-12);
  border-radius: var(--radius-8); background-color: var(--color-background); border: 1px solid var(--color-border);
  white-space: pre-wrap; word-break: break-word;
}
.comment .author { font-weight: 600; font-size: 14px; }
.comment .time { font-size: 12px; color: var(--color-muted); }

.history {
  display: flex; flex-direction: column; gap: var(--space-4); font-size: 14px;
  line-height: 24px; color: var(--color-muted); padding: var(--space-8) 0;
  border-bottom: 1px solid var(--color-background);
}

.notice, .error, .success, .warning {
  padding: var(--space-12) var(--space-16); border-radius: var(--radius-8);
  font-size: 14px; line-height: 24px; display: flex; align-items: center; gap: var(--space-12);
}
.notice {
  background-color: var(--color-background); color: var(--color-text); border: 1px solid var(--color-border);
  min-width: 0; word-break: break-word; overflow-wrap: break-word;
}
.notice.info { background-color: var(--color-doing-bg); color: var(--color-doing-text); border: 1px solid #bfdbfe; }
.notice.error, .error { background-color: var(--color-danger-bg); color: var(--color-danger); border: 1px solid #fecaca; }
.notice.success, .success { background-color: var(--color-done-bg); color: var(--color-done-text); border: 1px solid #bbf7d0; }
.notice.warning, .warning { background-color: var(--color-warning-bg); color: var(--color-warning-text); border: 1px solid #fef3c7; }

.empty { text-align: center; padding: 48px var(--space-16); color: var(--color-muted); font-size: 14px; line-height: 24px; }
.loading { display: flex; align-items: center; justify-content: center; padding: 48px var(--space-16); color: var(--color-muted); }
.skeleton { background-color: #e5e5e5; border-radius: var(--radius-8); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-16);
  font-size: 14px; line-height: 24px; color: var(--color-muted); padding: var(--space-16) 0; flex-wrap: wrap;
}

.conflict {
  background-color: var(--color-danger-bg); border: 1px solid #fecaca; border-radius: var(--radius-8);
  padding: var(--space-16); display: flex; flex-direction: column; gap: var(--space-12);
}
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-16); }
.muted { color: var(--color-muted); }
.divider { height: 1px; background-color: var(--color-border); width: 100%; }

.confirmation {
  margin: auto; padding: 24px; width: min(480px, calc(100vw - 32px));
  color: var(--color-text); background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-8);
}
.confirmation::backdrop { background: rgb(0 0 0 / 35%); }
.confirmation h2, .confirmation p { margin-bottom: 16px; }
.confirmation .actions { justify-content: flex-end; }
.error:has(h1) { flex-direction: column; align-items: flex-start; }
.badge.warning { padding: 0 12px; }
h1[tabindex="-1"]:focus { outline: none; }

/* Language picker */
.language-picker, .form-row.language-picker {
  display: inline-flex; align-items: center; gap: var(--space-12);
  width: auto; max-width: 100%; flex-wrap: wrap; min-width: 0;
}
.language-picker label, .form-row.language-picker label {
  font-size: 14px; font-weight: 500; color: var(--color-muted); white-space: nowrap;
}
.language-picker select, .form-row.language-picker select {
  font-family: inherit; font-size: 14px; min-height: 44px; padding: 8px var(--space-12);
  background-color: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-8); color: var(--color-text); width: auto;
}
.language-picker select:focus-visible, .form-row.language-picker select:focus-visible {
  outline: 2px solid var(--color-primary); outline-offset: 2px;
}

/* Settings page */
.settings-page { width: 100%; max-width: 1000px; display: flex; flex-direction: column; }
.settings-intro {
  display: flex; flex-direction: column; gap: var(--space-4);
  padding-bottom: var(--space-24); border-bottom: 1px solid var(--color-border);
}
.settings-intro h1 { font-size: 24px; font-weight: 600; line-height: 32px; color: var(--color-text); }
.settings-intro p, .settings-intro .subtitle { font-size: 14px; line-height: 20px; color: var(--color-muted); }
.settings-section {
  padding: var(--space-32) 0; border-bottom: 1px solid var(--color-border);
  display: grid; grid-template-columns: 200px minmax(0, 480px); gap: var(--space-32); align-items: start;
}
.settings-section:last-child { border-bottom: none; }
.settings-section-heading { display: flex; flex-direction: column; gap: var(--space-4); }
.settings-section-heading h2 { font-size: 16px; font-weight: 600; line-height: 24px; color: var(--color-text); }
.settings-section-heading p, .settings-section-heading .hint {
  font-size: 13px; line-height: 20px; color: var(--color-muted); max-width: 30ch;
}
.settings-section-body { display: flex; flex-direction: column; gap: var(--space-16); min-width: 0; }
.settings-section-body .form, .form[data-form="profile"], .form[data-form="password"] { max-width: 480px; width: 100%; }
.settings-password-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-16); width: 100%; }

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .settings-section { grid-template-columns: 1fr; gap: var(--space-16); padding: var(--space-24) 0; }
  .settings-section-heading p, .settings-section-heading .hint { max-width: 100%; }
}

@media (max-width: 767px) {
  .app-shell { flex-direction: column; }
  .sidebar { display: flex; width: 100%; border-right: none; border-bottom: 1px solid var(--color-border); padding: 8px 16px; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .main { padding: var(--space-16); }
  .app-header {
    height: auto; min-height: 56px; padding: var(--space-12) var(--space-16);
    flex-wrap: wrap; gap: var(--space-12);
  }
  .app-header h1, .app-header .brand { font-size: 16px; line-height: 24px; }
  .app-header .actions { min-width: 0; max-width: 100%; flex-wrap: wrap; }
  .app-header .user-name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;
  }
  .form-row { flex-direction: column; }
  .compare { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: visible; }
  .task-table, .project-table, .member-table,
  .task-table tbody, .project-table tbody, .member-table tbody,
  .task-table tr, .project-table tr, .member-table tr,
  .task-table td, .project-table td, .member-table td { display: block; }
  .task-table thead, .project-table thead, .member-table thead { display: none; }
  .task-table tbody, .project-table tbody, .member-table tbody { display: flex; flex-direction: column; gap: var(--space-12); }
  .task-table tr, .project-table tr, .member-table tr {
    display: flex; flex-direction: column; gap: var(--space-12);
    border: 1px solid var(--color-border); border-radius: var(--radius-8);
    padding: var(--space-12); background-color: var(--color-surface);
  }
  .task-table td, .project-table td, .member-table td {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--space-4) 0; border-bottom: none; min-height: 32px;
    min-width: 0; gap: var(--space-12);
  }
  .task-table td[data-label]::before,
  .project-table td[data-label]::before,
  .member-table td[data-label]::before {
    content: attr(data-label); font-weight: 600; color: var(--color-muted);
    margin-right: var(--space-12); flex-shrink: 0; max-width: 40%;
  }
  .task-table td > *, .project-table td > *, .member-table td > *,
  .task-table a, .project-table a, .member-table a {
    min-width: 0; word-break: break-word; overflow-wrap: break-word;
  }
}

@media (max-width: 600px) {
  .settings-password-row { grid-template-columns: 1fr; }
}

.task-title { max-width: 32ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-heading .title:has(> .task-title) { min-width: 0; overflow: hidden; max-width: 100%; }
form[data-form="register"] .field input[type="text"][aria-invalid="true"],
form[data-form="register"] .field input[type="password"][aria-invalid="true"],
form[data-form="register"] .field.has-error input[type="text"],
form[data-form="register"] .field.has-error input[type="password"] { border-color: var(--color-border); }
@media (max-width: 480px) {
  form[data-form="filters"].filters {
    min-width: 680px;
    flex-wrap: nowrap;
    flex-direction: row;
  }
}
