/* =========================================================
   Grinity TMS — Corporate UI
   Brand: teal primary (#187068) + orange accent (#F0A038) from logo.png
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --brand: #187068;
  --brand-strong: #0F5A54;
  --brand-hover: #0C4E49;
  --brand-soft: #E8F3F1;
  --brand-ring: rgba(24, 112, 104, 0.18);
  --accent: #F0A038;
  --accent-soft: #FFF6E8;

  --ink: #1F2937;
  --ink-2: #334155;
  --muted: #6B7280;
  --muted-2: #9CA3AF;
  --line: #E5E7EB;
  --line-2: #F1F5F9;
  --bg: #F7F7F8;
  --card: #FFFFFF;
  --sidebar: #FFFFFF;
  --sidebar-border: #EEF0F3;
  --danger: #EF4444;
  --success: #22C55E;
  --info: #3B82F6;
  --purple: #8B5CF6;
  --teal: #187068;
  --yellow: #F59E0B;
  --pink: #EC4899;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
  --sidebar-w: 280px;
  --header-h: 64px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 16px; font-weight: 600; cursor: pointer;
  transition: .15s ease; line-height: 1.2;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); color: #fff; }
.btn-outline {
  background: #fff; border-color: var(--line); color: var(--ink-2);
}
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ========== AUTH / LOGIN ========== */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: #fff;
}
.auth-visual {
  position: relative;
  background: #0F5A54;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  overflow: hidden;
  min-height: 100vh;
}
.auth-visual-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
}
.auth-visual-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(135deg, rgba(15, 90, 84, 0.35), rgba(24, 112, 104, 0.15));
  pointer-events: none;
}
.auth-visual-blob,
.auth-visual-art {
  display: none;
}
.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 72px;
  position: relative;
  min-height: 100vh;
}
.auth-brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 42px;
}
.brand-logo {
  display: block;
  width: auto;
  height: auto;
  object-fit: contain;
}
.brand-logo-login {
  height: 52px;
  max-width: 280px;
}
.brand-logo-sidebar {
  height: 36px;
  max-width: 200px;
}
.sidebar-brand-link {
  display: inline-flex;
  align-items: center;
}
.auth-title { font-size: 34px; font-weight: 700; margin: 0 0 8px; color: #111827; letter-spacing: -0.03em; }
.auth-subtitle { margin: 0 0 32px; color: var(--muted); font-size: 14.5px; }

.form-group { margin-bottom: 22px; }
.form-label {
  display: block; margin-bottom: 8px;
  font-size: 13.5px; font-weight: 500; color: var(--ink-2);
}
.input-line {
  position: relative;
  display: flex; align-items: center;
  border-bottom: 1px solid #D1D5DB;
  transition: border-color .15s ease;
}
.input-line:focus-within { border-bottom-color: var(--brand); }
.input-line input {
  width: 100%; border: 0; outline: 0; background: transparent;
  padding: 10px 36px 10px 0; color: var(--ink); font-size: 14.5px;
}
.input-line .input-icon {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  color: var(--muted-2); background: none; border: 0; padding: 4px; cursor: pointer;
  display: inline-flex;
}
.auth-row {
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 0 24px;
}
.checkbox {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ink-2); font-size: 13.5px; cursor: pointer; user-select: none;
}
.checkbox input { width: 15px; height: 15px; accent-color: var(--brand); }
.link-brand { color: var(--brand); font-weight: 600; font-size: 13.5px; }
.link-brand:hover { color: var(--brand-hover); }
.auth-submit { margin-top: 4px; padding: 13px 16px; font-size: 15px; border-radius: 6px; }
.auth-footer {
  position: absolute; left: 0; right: 0; bottom: 22px;
  text-align: center; color: var(--muted-2); font-size: 12px;
}
.auth-footer a {
  color: var(--brand);
  font-weight: 600;
}
.auth-footer a:hover {
  color: var(--brand-hover);
  text-decoration: underline;
}
.alert {
  border-radius: 8px; padding: 12px 14px; margin-bottom: 18px; font-size: 13.5px;
}
.alert-danger { background: #FEF2F2; color: #B91C1C; border: 1px solid #FECACA; }
.alert-success { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }

@media (max-width: 992px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-panel { padding: 40px 24px 72px; }
}

/* ========== APP SHELL ========== */
.app-shell { min-height: 100vh; display: flex; background: var(--bg); }
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  z-index: 40;
}
.sidebar-brand {
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px; border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-search { padding: 14px 16px 8px; }
.sidebar-search .search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; color: var(--muted);
}
.sidebar-search input {
  border: 0; outline: 0; background: transparent; width: 100%; color: var(--ink);
}
.sidebar-nav {
  flex: 1; overflow: auto; padding: 8px 12px 20px;
}
.nav-section-label {
  font-size: 11px; font-weight: 700; color: var(--muted-2);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--ink-2); font-weight: 500; margin-bottom: 2px;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; color: #64748B; }
.nav-item:hover { background: #F8FAFC; color: var(--ink); }
.nav-item.active {
  background: var(--brand-soft); color: var(--brand); font-weight: 600;
}
.nav-item.active svg { color: var(--brand); }
.nav-item .badge-new {
  margin-left: auto; background: #EF4444; color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 999px; padding: 2px 7px;
}
.nav-sub { padding-left: 12px; margin-bottom: 6px; }
.nav-sub a {
  display: block; padding: 7px 12px 7px 28px; border-radius: 6px;
  color: var(--muted); font-size: 13px;
}
.nav-sub a:hover, .nav-sub a.active { color: var(--brand); background: var(--brand-soft); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; position: sticky; top: 0; z-index: 30;
}
.topbar-search {
  flex: 1; max-width: 420px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; color: var(--muted);
}
.topbar-search input { border: 0; outline: 0; background: transparent; width: 100%; }
.topbar-search .kbd {
  font-size: 11px; color: var(--muted-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 2px 6px; background: #fff; white-space: nowrap;
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  color: #64748B; cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 8px; width: 8px; height: 8px;
  background: #EF4444; border-radius: 50%; border: 2px solid #fff;
}
.user-chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 4px 8px 4px 4px; border-radius: 999px; border: 0; background: transparent;
  cursor: pointer; margin-left: 4px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #2A9A8E, #187068);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.user-meta { text-align: left; line-height: 1.15; }
.user-meta strong { display: block; font-size: 13px; color: var(--ink); }
.user-meta span { font-size: 11.5px; color: var(--muted); }

.content { padding: 20px 22px 28px; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.breadcrumb { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb .sep { opacity: .5; }
.page-title { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.page-actions { display: flex; gap: 10px; align-items: center; }

.card {
  background: var(--card); border: 1px solid #EEF0F3;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-body { padding: 16px 18px; }
.card-title {
  margin: 0 0 14px; font-size: 15px; font-weight: 700; color: var(--ink);
  display: flex; align-items: center; justify-content: space-between;
}

.welcome-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 20px; margin-bottom: 18px;
  background: #fff; border: 1px solid #EEF0F3; border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.welcome-left { display: flex; align-items: center; gap: 14px; }
.welcome-left .avatar { width: 52px; height: 52px; font-size: 18px; }
.welcome-text h2 { margin: 0 0 4px; font-size: 18px; }
.welcome-text p { margin: 0; color: var(--muted); font-size: 13px; }
.welcome-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.stat-card {
  background: #fff; border: 1px solid #EEF0F3; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px;
  min-height: 0;
  display: flex; flex-direction: row; align-items: center; gap: 12px;
}
.stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 0; color: #fff; flex-shrink: 0;
}
.stat-icon.red { background: #F87171; }
.stat-icon.teal { background: #2DD4BF; }
.stat-icon.blue { background: #60A5FA; }
.stat-icon.pink { background: #F472B6; }
.stat-icon.purple { background: #A78BFA; }
.stat-icon.yellow { background: #FBBF24; }
.stat-icon.green { background: #34D399; }
.stat-icon.dark { background: #1F2937; }
.stat-body {
  min-width: 0; flex: 1;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-label {
  color: var(--muted); font-size: 12px; margin-bottom: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-value {
  font-size: 18px; font-weight: 800; letter-spacing: -0.03em;
  margin-bottom: 0; line-height: 1.2; color: var(--ink);
}
.stat-link { margin-top: 0; font-size: 11.5px; font-weight: 600; color: var(--brand); }

.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 16px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-label { width: 110px; color: var(--muted); font-size: 12.5px; }
.bar-track { flex: 1; height: 10px; background: #F1F5F9; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--brand); }
.bar-val { width: 34px; text-align: right; font-weight: 600; font-size: 12.5px; }

.stack-bar {
  height: 14px; border-radius: 999px; overflow: hidden; display: flex; margin: 12px 0 16px;
}
.stack-bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 12px 18px; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.dot-c { width: 8px; height: 8px; border-radius: 50%; }

.list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line-2);
}
.list-row:last-child { border-bottom: 0; }
.list-meta { flex: 1; min-width: 0; }
.list-meta strong { display: block; font-size: 13px; }
.list-meta span { color: var(--muted); font-size: 12px; }
.pill {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 3px 9px; font-size: 11.5px; font-weight: 600;
}
.pill-success { background: #DCFCE7; color: #166534; }
.pill-danger { background: #FEE2E2; color: #991B1B; }
.pill-warning { background: #FEF3C7; color: #92400E; }
.pill-info { background: #DBEAFE; color: #1E40AF; }
.pill-purple { background: #EDE9FE; color: #5B21B6; }

.todo-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 8px;
  font-size: 13px; font-weight: 500;
}
.todo-item input { accent-color: var(--brand); }
.todo-blue { background: #EFF6FF; }
.todo-green { background: #ECFDF5; }
.todo-purple { background: #F5F3FF; }
.todo-pink { background: #FDF2F8; }
.todo-yellow { background: #FFFBEB; }

.chart-placeholder {
  height: 220px; display: flex; align-items: flex-end; gap: 8px; padding: 8px 4px 0;
}
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-bars { width: 100%; display: flex; align-items: flex-end; gap: 3px; height: 170px; }
.chart-bars i { display: block; width: 50%; border-radius: 4px 4px 0 0; }
.chart-bars .inc { background: var(--brand); }
.chart-bars .exp { background: #E5E7EB; }
.chart-bar-col span { font-size: 10px; color: var(--muted-2); }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
  padding: 10px 8px; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 8px; border-bottom: 1px solid var(--line-2); font-size: 13px; vertical-align: middle; }
.progress {
  height: 6px; background: #F1F5F9; border-radius: 999px; overflow: hidden; min-width: 80px;
}
.progress > span { display: block; height: 100%; background: var(--brand); }

.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut {
  width: 150px; height: 150px; border-radius: 50%;
  background: conic-gradient(var(--brand) 0 40%, #60A5FA 40% 64%, #F87171 64% 80%, var(--accent) 80% 100%);
  mask: radial-gradient(circle at center, transparent 58%, #000 59%);
  -webkit-mask: radial-gradient(circle at center, transparent 58%, #000 59%);
  flex-shrink: 0;
}
.activity-item { display: flex; gap: 12px; padding: 10px 0; }
.activity-item .time { color: var(--muted-2); font-size: 11.5px; margin-top: 2px; }

.app-footer {
  margin-top: auto; padding: 14px 22px; color: var(--muted-2); font-size: 12px;
  display: flex; justify-content: space-between; border-top: 1px solid var(--line-2);
  background: transparent; gap: 12px; flex-wrap: wrap;
}
.app-footer a {
  color: var(--brand);
  font-weight: 600;
}
.app-footer a:hover {
  color: var(--brand-hover);
  text-decoration: underline;
}

.dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-md); min-width: 180px; padding: 6px; z-index: 50;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px 12px; border-radius: 8px; color: var(--ink-2); cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg); }

@media (max-width: 1100px) {
  .grid-2, .grid-3, .grid-2-1 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar { display: none; }
}
@media (max-width: 768px) {
  .stat-grid { grid-template-columns: 1fr; }
  .welcome-card { flex-direction: column; align-items: flex-start; }
  .topbar-search { display: none; }
  .content { padding: 16px; }
}

/* ========== LIST / ORG CRUD (Phase 3) ========== */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 14px;
}
.toolbar-search { max-width: 280px; }
.toolbar-select { max-width: 200px; }
.table-wrap { overflow-x: auto; }
.table-actions {
  display: flex; gap: 8px; align-items: center; justify-content: flex-end; white-space: nowrap;
}
.inline-form { display: inline; margin: 0; }
.inline-controls { display: flex; gap: 10px; align-items: center; }
.inline-controls .form-control { flex: 1; }
.member-add-form { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.empty-cell { color: var(--muted); text-align: center; padding: 28px 8px !important; }
.muted-sm { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.form-card { max-width: 860px; }
.btn-danger {
  background: #FEF2F2; color: #B91C1C; border: 1px solid #FECACA;
}
.btn-danger:hover { background: #FEE2E2; color: #991B1B; }
.table a { color: var(--brand); font-weight: 600; }
.table a:hover { text-decoration: underline; }

/* ========== APP FORMS (Phase 2) ========== */
.app-form .form-group { margin-bottom: 16px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.form-control {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.form-control:disabled {
  background: var(--bg);
  color: var(--muted);
}
.form-actions {
  display: flex; gap: 10px; align-items: center; margin-top: 8px;
}
.meta-list > div {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line-2);
  font-size: 13px;
}
.meta-list > div span { color: var(--muted); }
.meta-list > div:last-child { border-bottom: 0; }
.content > .alert { margin-bottom: 14px; }
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
}
