/* Global layout and theme */
:root {
  --bg: #e7ecf5;
  --card: #ffffff;
  --card-soft: #f3f6fc;
  --border: #c7d2e3;
  --text: #0b1324;
  --muted: #4b5568;
  --accent: #2563eb;
  --accent-2: #0ea5e9;
  --danger: #e11d48;
  --warning: #f59e0b;
  --shadow: 0 10px 25px rgba(12, 16, 31, 0.16);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f7f9ff 0%, #e7ecf5 65%, #dde4f1 100%);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", "SF Pro Display", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}

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

.page { max-width: 1200px; margin: 0 auto; padding: 28px 24px 60px; }

header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #eff6ff; font-weight: 800; box-shadow: var(--shadow);
}
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.5px; }
.subtle { color: var(--muted); font-size: 13px; }

nav { display: flex; gap: 10px; flex-wrap: wrap; }
nav a {
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: #f9fbff; color: var(--text); transition: all 0.15s ease;
}
nav a:hover { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12); }

.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-soft) 100%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 18px 16px; box-shadow: var(--shadow);
}
.card h2, .card h3 { margin: 0 0 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.section-title {
  margin: 8px 0 6px; font-size: 13px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px;
}

.alert { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 12px; background: #eef4ff; color: var(--text); }
.alert-success { border-color: rgba(37, 99, 235, 0.4); }
.alert-warning { border-color: rgba(245, 158, 11, 0.5); background: #fff9eb; }
.alert ul { margin: 6px 0 0 18px; }

.muted { color: var(--muted); font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: #eff4ff; color: var(--text); font-weight: 600; line-height: 1.2;
  cursor: pointer; transition: all 0.15s ease;
}
.btn:hover { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #eff6ff; border: none; }
.btn-primary:hover { box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.18); }
.btn-ghost { background: transparent; }
.btn-danger { background: linear-gradient(135deg, var(--danger), #be123c); color: #fff; border: none; }
.btn-sm { padding: 8px 12px; font-size: 14px; }
.project-btn { min-width: 86px; justify-content: center; height: 36px; }

label { display: block; margin-bottom: 4px; font-weight: 600; }

input[type="text"], input[type="password"], input[type="file"], textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: #f9fbff; color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18); }
textarea { resize: vertical; min-height: 90px; }

table { width: 100%; border-collapse: collapse; margin-top: 8px; }
th, td { border: 1px solid var(--border); padding: 10px; text-align: left; }
th { background: #e7edfb; font-weight: 700; }
.table tbody tr:nth-child(odd) { background: #f9fbff; }
.table tbody tr:nth-child(even) { background: #f3f6fc; }
.table td { background: transparent; }
.table.sticky thead { position: sticky; top: 0; z-index: 2; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(37, 99, 235, 0.12); color: var(--text);
  border: 1px solid rgba(37, 99, 235, 0.35); font-size: 13px; font-weight: 600;
}

.list-grid a {
  display: block; padding: 12px; border-radius: 10px; border: 1px solid var(--border);
  background: #f9fbff; color: var(--text); transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.list-grid a:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: 0 12px 25px rgba(15, 23, 42, 0.12); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.badge { display: inline-block; background: rgba(37, 99, 235, 0.15); border: 1px solid rgba(37, 99, 235, 0.3); color: var(--text); padding: 4px 8px; border-radius: 8px; font-size: 13px; }
.helper { background: #f8fbff; border: 1px dashed var(--border); border-radius: 10px; padding: 10px 12px; color: var(--muted); font-size: 13px; }

.inline-actions { display: flex; gap: 6px; align-items: center; }
.inline-actions.column { flex-direction: column; align-items: stretch; gap: 8px; }
.inline-input, .inline-select { width: 100%; }
.inline-input.wide { min-width: 160px; }

.projects-layout { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.projects-layout > .stack { min-width: 0; }
.sidebar-card { position: static; }
.stack { display: grid; gap: 12px; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.notice {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.12);
  color: var(--text);
  font-size: 14px;
}
.notice-error {
  border-color: rgba(220, 38, 38, 0.35);
  background: rgba(220, 38, 38, 0.12);
}

.project-list { display: grid; gap: 10px; }
.project-card {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f9fbff;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.project-card:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: 0 12px 25px rgba(15, 23, 42, 0.12); }
.project-card-title { font-weight: 600; margin-bottom: 4px; }
.project-meta, .ticket-meta { font-size: 12px; color: var(--muted); }
.ticket-title { font-weight: 600; }

.table-wrap { overflow-x: auto; }

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.toast {
  position: fixed; right: 18px; bottom: 18px;
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 12px 14px; border-radius: 10px; display: none;
}

@media (min-width: 1180px) {
  .projects-layout { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
  .sidebar-card { position: sticky; top: 12px; }
}

/* Ticket cards (project detail) */
.ticket-list { display: grid; gap: 12px; }
.ticket-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #f9fbff;
}
.ticket-card .top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  align-items: center;
}
.ticket-card .top-row .code { font-weight: 700; }
.ticket-card .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.ticket-card .actions .btn { width: 90px; }

@media (max-width: 720px) {
  .ticket-card .top-row { grid-template-columns: 1fr; }
  .ticket-card .actions { justify-content: flex-start; }
}

@media (max-width: 720px) {
  header { flex-direction: column; align-items: flex-start; }
  nav { width: 100%; }
  .form-actions { flex-direction: column; }
}
