:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-alt: #f8f9fa;
  --primary: #0052cc;
  --primary-soft: #e9f2ff;
  --text: #17212f;
  --muted: #6b778c;
  --line: #dfe1e6;
  --success: #0b8f5a;
  --success-soft: #dcfce7;
  --warning: #b26a00;
  --warning-soft: #fff4db;
  --danger: #c62828;
  --danger-soft: #fde7e7;
  --shadow: 0 2px 6px rgba(9, 30, 66, 0.08);
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  flex: 1;
}

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 4px 6px 14px;
  color: #1f2937;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.sidebar-group {
  display: grid;
  gap: 4px;
  padding: 8px 0;
}

.sidebar-group + .sidebar-group {
  border-top: 1px solid var(--line);
  margin-top: 8px;
}

.sidebar-group-title {
  margin: 0 8px 4px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted);
}

.nav-link {
  text-decoration: none;
  color: #374151;
  font-weight: 700;
  font-size: 0.86rem;
  border-radius: 8px;
  padding: 9px 10px;
  border: 1px solid transparent;
}

.nav-link:hover {
  background: #f3f4f6;
}

.nav-link.is-active {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: #cfe1ff;
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-main > .container {
  flex: 1;
}

.container {
  width: 80%;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: #ffffff;
  margin-top: 16px;
}

.site-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 16px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-links a {
  color: #4b5563;
  text-decoration: none;
  font-weight: 600;
}

.footer-links a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.topbar {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.brand {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  transition: 0.15s ease;
  line-height: 1.2;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: #0044b3;
}

.btn-secondary {
  background: #eef1f5;
  color: var(--text);
  border-color: var(--line);
}
.btn-secondary:hover {
  background: #e4e8ee;
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #f1c5c5;
}
.btn-danger:hover {
  background: #f9d6d6;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  padding: 14px 16px;
  background: var(--panel-alt);
  border-color: var(--line);
}

.stat-good {
  background: #f2fff7;
  border-color: #b9ebce;
}

.stat-good .stat-value,
.stat-good .stat-label {
  color: var(--success);
}

.stat-bad {
  background: #fff5f5;
  border-color: #f1c5c5;
}

.stat-bad .stat-value,
.stat-bad .stat-label {
  color: var(--danger);
}

.stat-neutral {
  background: var(--panel-alt);
  border-color: var(--line);
}

.stat-label {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.stat-value {
  margin-top: 8px;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
}

.panel {
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

.kanban-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 6px 0 18px;
}

.kanban-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 16px;
  align-items: start;
}

.kanban-column {
  background: #f2f3f5;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  min-height: 240px;
}

.kanban-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 4px 6px;
}

.kanban-title {
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kanban-count {
  background: #dfe3ec;
  color: #4b5563;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 7px;
  min-width: 22px;
  text-align: center;
}

.kanban-cards {
  display: grid;
  gap: 10px;
}

.kanban-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 1px 0 rgba(9, 30, 66, 0.04);
}

.kanban-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.card-id {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.kanban-card-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}

.kanban-card-subtitle {
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 10px;
}

.kanban-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--muted);
  padding: 4px 0;
  border-top: 1px solid rgba(23, 29, 35, 0.06);
}

.kanban-meta strong {
  color: var(--text);
  font-weight: 700;
}

.kanban-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.kanban-empty {
  background: rgba(255, 255, 255, 0.4);
  border: 1px dashed var(--line);
  color: var(--muted);
  border-radius: 8px;
  padding: 16px 10px;
  text-align: center;
  font-size: 0.85rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal-dialog {
  width: min(1100px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  padding: 0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-close {
  color: var(--muted);
  text-decoration: none;
  font-size: 1.8rem;
  line-height: 1;
  padding: 0 4px;
}

.modal-dialog .property-card {
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: #fff;
  padding: 18px 20px 0;
}

form {
  display: grid;
  gap: 16px;
}

.modal-form-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 18px;
  margin: 0 -20px;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(2px);
  box-shadow: 0 -8px 22px rgba(15, 23, 42, 0.04);
}

.modal-form-footer .btn {
  min-width: 120px;
  padding: 9px 14px;
  font-size: 0.88rem;
  border-radius: 6px;
  font-weight: 700;
  box-shadow: none;
}

.modal-form-footer .btn-secondary {
  background: #f3f4f6;
  border-color: var(--line);
  color: var(--text);
}

.modal-form-footer .btn-secondary:hover {
  background: #e9edf3;
  border-color: #d7dce3;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.property-card {
  background: #f7f7f5;
  border: 1px solid #e7e5e4;
  border-radius: 12px;
  padding: 18px 18px 10px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.property-header {
  padding: 2px 4px 14px;
  border-bottom: 1px solid #e7e5e4;
  margin-bottom: 10px;
}

.page-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}

.property-title {
  margin: 0;
  font-size: clamp(1.9rem, 2vw, 2.6rem);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #1f2328;
}

.property-list {
  display: grid;
  gap: 8px;
}

.property-row {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 38px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(23, 29, 35, 0.06);
}

.property-label {
  width: 220px;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #4b5563;
}

.property-input {
  flex: 1;
  display: flex;
  align-items: center;
}

.inline-dual-field {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(120px, 140px);
  gap: 10px;
  width: 100%;
}

.field-with-caption {
  display: grid;
  gap: 4px;
  width: 100%;
}

.mini-caption {
  font-size: 0.68rem;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: var(--muted);
  padding-left: 2px;
  margin-bottom: 4px;
}

.stacked-field-label {
  font-size: 0.68rem;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: var(--muted);
  padding-left: 2px;
  margin-bottom: 6px;
  display: block;
}

.stacked-field-label.group-title {
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(23, 29, 35, 0.12);
}

.property-list.stacked-labels .property-row {
  display: block;
  min-height: 0;
  padding: 8px 0;
}

.property-list.stacked-labels .property-label {
  display: none;
}

.property-list.stacked-labels .property-input {
  width: 100%;
  display: block;
}

.currency-field,
.percent-field {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.currency-field .field-prefix,
.percent-field .field-suffix {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 700;
  pointer-events: none;
  font-size: 0.9rem;
}

.currency-field .field-prefix {
  left: 10px;
}

.percent-field .field-suffix {
  right: 10px;
}

.currency-field input {
  padding-left: 30px;
}

.percent-field input {
  padding-right: 30px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.92rem;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(0, 82, 204, 0.2);
  border-color: var(--primary);
}

input[readonly],
input[disabled] {
  background: #f3f4f6;
  color: #5f6b7a;
  cursor: not-allowed;
}

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

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

th {
  background: var(--panel-alt);
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
}

tbody tr:hover {
  background: #fafbff;
}

.status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--line);
}

.status-pending {
  background: var(--warning-soft);
  color: var(--warning);
}
.status-processing {
  background: var(--primary-soft);
  color: var(--primary);
}
.status-completed {
  background: var(--success-soft);
  color: var(--success);
}
.status-cancelled {
  background: var(--danger-soft);
  color: var(--danger);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.login-box h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

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

.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f1c5c5;
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid #b9ebce;
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: grid;
  gap: 10px;
  max-width: min(420px, calc(100vw - 24px));
}

.toast {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 10px 22px rgba(9, 30, 66, 0.18);
  color: var(--text);
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.toast-success {
  border-left-color: var(--success);
  background: #f4fff8;
}

.toast-error {
  border-left-color: var(--danger);
  background: #fff7f7;
}

.toast-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 2px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
  }

  .sidebar-title {
    margin: 2px 2px 8px;
  }

  .sidebar-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .sidebar-group {
    display: contents;
    padding: 0;
  }

  .sidebar-group + .sidebar-group {
    border-top: 0;
    margin-top: 0;
  }

  .sidebar-group-title {
    display: none;
  }

  .site-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}
