:root {
  --bg: #f4f7fb;
  --bg-soft: #ffffff;
  --bg-muted: #eef2f7;
  --text: #162233;
  --text-soft: #5b6b7f;
  --border: #d9e2ee;
  --primary: #1f6feb;
  --primary-hover: #195dcc;
  --success: #198754;
  --danger: #dc3545;
  --warning: #f59e0b;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
  --bg: #0c0c0d;
  --bg-soft: #141416;
  --bg-muted: #1c1c1f;
  --text: #f2f2f3;
  --text-soft: #a8a8ad;
  --border: #2b2b30;
  --primary: #5f8cff;
  --primary-hover: #4f7beb;
  --success: #23a46c;
  --danger: #e55a66;
  --warning: #e8ae4c;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: radial-gradient(circle at top right, #dbeafe 0%, var(--bg) 38%);
  color: var(--text);
  min-height: 100vh;
}
[data-theme="dark"] body {
  background: radial-gradient(circle at top right, #202024 0%, var(--bg) 36%);
}

.main-header {
  position: sticky;
  top: 0;
  z-index: 1200;
  background: color-mix(in srgb, var(--bg-soft) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-content {
  max-width: 1380px;
  margin: 0 auto;
  min-height: 68px;
  padding: 10px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.logo-link {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
}
.site-logo {
  height: 44px;
  width: auto;
  display: block;
  object-fit: contain;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0;
  text-decoration: none;
  color: var(--text-soft);
  border: 1px solid transparent;
  padding: 8px 11px;
  border-radius: 9px;
  transition: all 0.22s ease;
}
.nav-text {
  line-height: 1.1;
  font-weight: 600;
}
.nav-link:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--primary) 38%, var(--border));
  background: var(--bg-muted);
}
.nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  border-color: transparent;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--primary) 35%, transparent);
}
[data-theme="dark"] .nav-link.active {
  color: #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.42);
}

.nav-dropdown {
  position: relative;
}
.nav-dropdown-toggle {
  cursor: pointer;
  list-style: none;
}
.nav-dropdown-toggle::-webkit-details-marker {
  display: none;
}
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 190px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  z-index: 1300;
}
.nav-dropdown[open] .nav-dropdown-menu {
  display: block;
}
.nav-dropdown[open] .nav-dropdown-toggle {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  border-color: transparent;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--primary) 35%, transparent);
}
[data-theme="dark"] .nav-dropdown[open] .nav-dropdown-toggle {
  color: #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.42);
}
.nav-dropdown-item {
  display: block;
  text-decoration: none;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
}
.nav-dropdown-item:hover {
  background: var(--bg-muted);
}
.nav-dropdown-item.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}
.notif-link {
  position: relative;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.notif-badge {
  position: absolute;
  top: -5px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #dc3545;
  color: #fff;
  font-size: 0.68rem;
  line-height: 16px;
  text-align: center;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.profile-dropdown {
  position: relative;
}

.profile-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
}

.profile-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.profile-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-caret {
  color: var(--text-soft);
  font-size: 0.8rem;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  display: none;
  z-index: 1300;
}

.profile-dropdown.open .profile-menu {
  display: block;
}

.profile-menu-head {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
}

.profile-menu-head small {
  color: var(--text-soft);
}

.profile-menu-item {
  display: block;
  text-decoration: none;
  color: var(--text);
  padding: 8px;
  border-radius: 8px;
}

.profile-menu-item:hover {
  background: var(--bg-muted);
}

.profile-menu-item-danger {
  color: var(--danger);
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: var(--bg-muted);
  border-radius: 9px;
  cursor: pointer;
}

.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  border: 0;
  background: transparent;
  cursor: pointer;
  justify-self: end;
}
.mobile-menu-toggle span {
  width: 23px;
  height: 2px;
  background: var(--text);
}

.container {
  max-width: 1380px;
  margin: 18px auto;
  padding: 0 18px;
}

.card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.page-header h1 { margin: 0 0 12px 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.text-muted, .muted { color: var(--text-soft); }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}
.stat-card { border-left: 4px solid var(--primary); }
.stats-compact .card {
  padding: 8px 10px;
  margin-bottom: 0;
}
.stats-compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.stats-compact .stat-card h3 {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.1;
  opacity: 0.9;
}
.stats-compact .stat-card p {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.stats-compact .stat-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
}

@media (max-width: 900px) {
  .stats-compact {
    grid-template-columns: 1fr;
  }
}

.table-wrap, .table-container { overflow-x: auto; border-radius: 11px; border: 1px solid var(--border); -webkit-overflow-scrolling: touch; }
table, .table, .operasyon-table { width: 100%; border-collapse: collapse; background: var(--bg-soft); min-width: 700px; }
th, td { border-bottom: 1px solid var(--border); padding: 10px; text-align: left; vertical-align: top; word-break: break-word; }
th { background: var(--bg-muted); font-size: 0.86rem; }
tbody tr:hover td { background: color-mix(in srgb, var(--bg-muted) 85%, transparent); }

.form-group { margin-bottom: 10px; }
label { display: block; font-weight: 600; margin-bottom: 5px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 10px;
  color: var(--text);
  background: var(--bg-soft);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 24%, transparent);
}
.grid-2, .form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }

.btn, .button {
  border: 0;
  border-radius: 9px;
  padding: 9px 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.2s ease;
}
.btn:hover, .button:hover { transform: translateY(-1px); filter: brightness(1.03); }
.btn-primary, .button, .button-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary, .button-secondary, .button-light { background: var(--bg-muted); color: var(--text); border: 1px solid var(--border); }
.btn-success, .button-success { background: var(--success); color: #fff; }
.btn-danger, .button-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 10px; font-size: 0.86rem; }
.form-submit-btn { margin-top: 12px; }
.inline-form { display: inline-block; }
.all-operations-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.operation-edit-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.operation-edit-tab-btn {
  border: 1px solid var(--border);
  background: var(--bg-muted);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
  font-size: 0.82rem;
}
.operation-edit-tab-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  border-color: transparent;
}
.operation-edit-panel { display: none; }
.operation-edit-panel.active { display: block; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.74rem;
  font-weight: 700;
}
.badge-success { background: var(--success); color: #fff; }
.badge-warning { background: var(--warning); color: #111; }

.alert {
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  transition: opacity 0.24s ease, transform 0.24s ease;
}
.alert-error { background: color-mix(in srgb, var(--danger) 18%, white); border: 1px solid color-mix(in srgb, var(--danger) 45%, white); color: #701c26; }
.alert-success { background: color-mix(in srgb, var(--success) 16%, white); border: 1px solid color-mix(in srgb, var(--success) 40%, white); color: #145531; }

.filter-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-muted);
  padding: 10px;
}
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.filter-group { flex: 1 1 220px; }
.filter-label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 0.86rem; }
.filter-input { width: 100%; }
.btn-filter-clear {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.gemi-selection-form { margin-top: 8px; }
.gemi-select-grid { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.gemi-select-label { display: block; margin-bottom: 6px; font-weight: 600; }

.plaka-column { min-width: 220px; }
.plaka-column span { display: block; margin-bottom: 3px; }

dialog.modal {
  width: min(920px, 94vw);
  border: none;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.35);
  background: var(--bg-soft);
  color: var(--text);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.62); }
.modal-card { padding: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.dusum-quick-flow-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  max-height: min(62vh, 560px);
  overflow: auto;
  padding-right: 2px;
}
.dusum-quick-flow-item {
  border: 1px solid var(--border);
  background: var(--bg-muted);
  border-radius: 10px;
  padding: 12px;
}
.dusum-quick-flow-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}
.dusum-quick-flow-main {
  display: grid;
  gap: 4px;
}
.dusum-quick-flow-plate {
  font-size: 1rem;
  line-height: 1.25;
}
.dusum-quick-flow-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.dusum-quick-flow-bottom form {
  flex: 1 1 360px;
}

@media (max-width: 960px) {
  .header-content {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
  }
  .logo {
    flex: 0 1 auto;
    min-width: 0;
  }
  .mobile-menu-toggle { display: flex; }
  .mobile-menu-toggle {
    margin-left: auto;
    flex: 0 0 auto;
  }
  .header-actions {
    flex: 0 0 auto;
    justify-self: auto;
    gap: 6px;
  }
  .profile-toggle {
    padding: 6px 7px;
    gap: 6px;
  }
  .main-nav {
    position: fixed;
    left: 0;
    top: 68px;
    width: min(84vw, 320px);
    height: calc(100vh - 68px);
    background: var(--bg-soft);
    border-right: 1px solid var(--border);
    transform: translateX(-105%);
    transition: transform 0.24s ease;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    z-index: 1250;
    justify-content: flex-start;
  }
  .main-nav.active { transform: translateX(0); }
  body.mobile-menu-open { overflow: hidden; }
  .nav-dropdown-menu {
    position: static;
    min-width: 0;
    border: 0;
    box-shadow: none;
    padding: 6px 0 0;
    display: block;
  }
  .nav-dropdown-toggle .profile-caret {
    display: none;
  }
  .gemi-select-grid { grid-template-columns: 1fr; }
  .profile-name { display: none; }
  .dusum-quick-flow-bottom .button {
    width: 100%;
  }
  .dusum-quick-flow-bottom form {
    flex-basis: 100%;
  }
  .dusum-quick-flow-top {
    flex-direction: column;
    align-items: stretch;
  }
  .dusum-quick-flow-plate {
    font-size: 0.96rem;
  }
  .section-head > div:last-child {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .section-head > div:last-child .button,
  .section-head > div:last-child .btn {
    flex: 1 1 180px;
  }
  dialog.modal {
    width: min(96vw, 920px);
    max-height: 92vh;
  }
  .modal-card {
    padding: 14px;
  }
}

@media (max-width: 720px) {
  .container { padding: 0 10px; }
  .header-content { padding: 10px; }
  table, .table, .operasyon-table { min-width: 560px; }
  .userbox { font-size: 0.8rem; }
  .site-logo { height: 38px; }
  .theme-toggle {
    width: 34px;
    height: 34px;
  }
  .header-actions {
    gap: 6px;
  }
  .profile-toggle {
    padding: 5px 6px;
  }
  .filter-group {
    flex: 1 1 100%;
  }
  .filter-row .button,
  .filter-row .btn,
  .filter-row .btn-filter-clear {
    flex: 1 1 calc(50% - 4px);
    min-height: 38px;
  }
  .all-operations-actions .button {
    flex: 1 1 100%;
  }
  .inline-form {
    width: 100%;
  }
  .inline-form .button {
    width: 100%;
  }
  th, td {
    padding: 8px;
    font-size: 0.86rem;
  }
}

@media (max-width: 420px) {
  table, .table, .operasyon-table { min-width: 520px; }
  .filter-row .button,
  .filter-row .btn,
  .filter-row .btn-filter-clear {
    flex: 1 1 100%;
  }
}
