:root {
  color-scheme: dark;
  --bg: #080a0c;
  --surface: #15191d;
  --surface-2: #1d2328;
  --ink: #f3f6f7;
  --muted: #a7b0b7;
  --line: #2d353c;
  --accent: #18d08d;
  --accent-2: #ffb347;
  --done: #7cb7ff;
  --cancel: #ff7272;
  --montaj: #2497ff;
  --imalat: #18d08d;
  --bekleme: #ffb347;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.34);
}

[hidden] { display: none !important; }
#usersDialog .backup-list { margin-top: 16px; }
#usersList .backup-row { grid-template-columns: minmax(0, 1fr) minmax(140px, 1fr); }

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}

button:hover {
  border-color: #b7beb7;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #06110d;
  font-weight: 700;
}

.danger {
  border-color: rgba(240, 113, 113, 0.42);
  background: rgba(240, 113, 113, 0.12);
  color: var(--cancel);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  padding: 10px clamp(14px, 4vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 10, 12, 0.88);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  overflow: visible;
}

.brand {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
  line-height: 1;
}

.month-controls {
  justify-self: end;
  align-self: center;
  grid-column: 2;
}

.quick-controls {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto auto auto;
  gap: 8px;
  justify-self: end;
  align-self: center;
  grid-column: 3;
}

.logo-frame {
  width: 58px;
  height: 72px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.logo-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: contrast(1.06) saturate(1.08);
}

.brand .eyebrow {
  margin-bottom: 5px;
}

.brand > div:last-child {
  min-width: 0;
  text-align: left;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 2.7vw, 32px);
  line-height: 1.05;
}

h2 {
  font-size: 20px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.month-controls {
  display: grid;
  grid-template-columns: 42px minmax(160px, auto) 42px;
  gap: 8px;
}

.quick-controls select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface);
}

.quick-controls .is-active {
  border-color: var(--accent-2);
  background: rgba(240, 160, 79, 0.16);
  color: var(--accent-2);
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.view-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.view-controls .is-active {
  border-color: var(--accent);
  background: rgba(48, 184, 137, 0.16);
  color: var(--accent);
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  padding: 18px clamp(14px, 4vw, 32px);
}

.auth-panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 10, 12, 0.92);
}

.auth-panel[hidden] {
  display: none;
}

.auth-box {
  width: min(380px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-error {
  min-height: 20px;
  color: var(--cancel);
  font-size: 13px;
}

.calendar-wrap,
.side-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.calendar-wrap {
  overflow: hidden;
}

.calendar-scroll {
  overflow-x: hidden;
}

.calendar-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.calendar-note {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.calendar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.search-input {
  width: min(260px, 100%);
  min-height: 42px;
}

.range-controls {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #101418;
}

.range-controls button,
.calendar-actions .is-active {
  min-height: 38px;
}

.range-controls .is-active,
.calendar-actions .is-active {
  border-color: var(--accent);
  background: rgba(24, 208, 141, 0.18);
  color: var(--accent);
  font-weight: 700;
}

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

.weekdays,
.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekdays {
  border-bottom: 1px solid var(--line);
  background: #111519;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.weekdays span {
  padding: 10px 8px;
  text-align: center;
}

.day {
  min-height: 128px;
  padding: 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
}

.day:nth-child(7n) {
  border-right: 0;
}

.day.is-other {
  background: #101316;
  color: #66717a;
}

.day.is-today {
  outline: 2px solid var(--accent-2);
  outline-offset: -2px;
}

.day.is-selected {
  background: rgba(48, 184, 137, 0.13);
}

.day.is-drop-target {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
  background: rgba(48, 184, 137, 0.2);
}

.day-number {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-weight: 700;
}

.count {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(48, 184, 137, 0.16);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.event-chip {
  width: 100%;
  min-height: 30px;
  margin-top: 5px;
  padding: 5px 7px;
  border: 0;
  border-left: 6px solid var(--accent);
  border-radius: 6px;
  background: rgba(24, 208, 141, 0.22);
  color: var(--ink);
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}

.event-chip:hover {
  border-left-color: var(--accent-2);
  background: rgba(24, 208, 141, 0.34);
}

.event-chip.type-montaj,
.event-card.type-montaj,
.mobile-event.type-montaj {
  border-left-color: var(--montaj);
  background: rgba(36, 151, 255, 0.24);
}

.event-chip.type-imalat,
.event-card.type-imalat,
.mobile-event.type-imalat {
  border-left-color: var(--imalat);
  background: rgba(24, 208, 141, 0.24);
}

.event-chip.type-bekleme,
.event-card.type-bekleme,
.mobile-event.type-bekleme {
  border-left-color: var(--bekleme);
  background: rgba(255, 179, 71, 0.25);
}

.event-chip.tamamlandi,
.event-card.tamamlandi,
.mobile-event.tamamlandi {
  border-left-color: #9aa4ad;
  background: rgba(125, 135, 145, 0.28);
  color: #c8d0d6;
  opacity: 0.72;
  text-decoration: none;
}

.event-chip.iptal {
  border-left-color: var(--cancel);
  background: rgba(255, 114, 114, 0.22);
  text-decoration: line-through;
}

.year-view {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.year-month {
  display: grid;
  gap: 8px;
  min-height: 140px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  text-align: left;
}

.year-month strong {
  font-size: 16px;
}

.year-month .count {
  justify-self: start;
  min-width: 28px;
  padding: 0 8px;
}

.year-list {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.side-panel {
  min-height: 360px;
  overflow: hidden;
}

.icon-btn {
  width: 42px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.day-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.mobile-list {
  display: grid;
  border-top: 1px solid var(--line);
  background: #101418;
}

.mobile-list[hidden] {
  display: none;
}

.mobile-day {
  display: grid;
  gap: 9px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.mobile-day.is-selected {
  background: rgba(24, 208, 141, 0.1);
}

.mobile-day.is-drop-target {
  background: rgba(24, 208, 141, 0.2);
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.trash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #11171b;
}

.overdue-head {
  background: rgba(255, 114, 114, 0.16);
  color: #ffd3d3;
}

.mobile-day-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--ink);
  text-align: left;
}

.mobile-day-title span {
  min-width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(48, 184, 137, 0.16);
  color: var(--accent);
  font-weight: 700;
}

.mobile-event {
  display: grid;
  gap: 5px;
  min-height: 54px;
  padding: 11px 12px;
  border-left: 6px solid var(--accent);
  background: var(--surface-2);
  text-align: left;
  cursor: grab;
}

.mobile-event.is-deleted {
  opacity: 0.78;
}

.mobile-event.is-overdue {
  border-left-color: var(--cancel);
  background: rgba(255, 114, 114, 0.18);
}

.priority-acil {
  border-color: rgba(255, 114, 114, 0.7);
  border-left-color: var(--cancel);
  background: rgba(255, 114, 114, 0.22);
}

.priority-beklemede {
  border-color: rgba(255, 179, 71, 0.55);
  border-left-color: var(--bekleme);
  background: rgba(255, 179, 71, 0.18);
}

.mobile-event span {
  color: var(--muted);
  font-size: 13px;
}

.mobile-event.tamamlandi span,
.event-card.tamamlandi .meta {
  color: #aeb7bf;
}

.event-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 8px;
  background: rgba(24, 208, 141, 0.18);
  text-align: left;
  cursor: pointer;
}

.customer-card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  background: var(--surface-2);
  cursor: pointer;
}

.customer-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.customer-card-head span {
  min-width: 44px;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(24, 208, 141, 0.16);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.customer-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.customer-step {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  font-weight: 700;
}

.customer-step.is-active {
  border-color: var(--accent-2);
  color: var(--accent-2);
  background: rgba(255, 179, 71, 0.16);
}

.customer-step.is-done {
  border-color: #9aa4ad;
  color: #c8d0d6;
  background: rgba(125, 135, 145, 0.18);
}

.customer-meta {
  color: var(--muted);
  font-size: 13px;
}

.event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.mini-action {
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
}

.mini-action.is-active {
  border-color: #9aa4ad;
  background: #9aa4ad;
  color: #071014;
  font-weight: 800;
}

.event-card.tamamlandi {
  border-color: rgba(154, 164, 173, 0.5);
}

.event-card.iptal {
  border-left-color: var(--cancel);
  opacity: 0.72;
}

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

.empty {
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

dialog {
  width: min(620px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--ink);
  background: var(--surface);
}

dialog::backdrop {
  background: rgba(16, 20, 22, 0.45);
}

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

.dialog-head,
.dialog-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.dialog-actions {
  grid-template-columns: auto 1fr auto auto;
  margin-top: 4px;
}

.backup-dialog {
  display: grid;
  gap: 14px;
}

.backup-note {
  color: var(--muted);
  font-size: 13px;
}

.backup-list {
  display: grid;
  gap: 8px;
  max-height: min(520px, 70vh);
  overflow: auto;
}

.backup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.backup-row div {
  display: grid;
  gap: 4px;
}

.backup-row span {
  color: var(--muted);
  font-size: 12px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  background: #0f1316;
}

textarea {
  resize: vertical;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 78px;
    overflow: hidden;
  }

  .brand {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .quick-controls {
    grid-column: 1 / -1;
    width: 100%;
    justify-self: stretch;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    min-height: 0;
  }

  .year-view {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .logo-frame {
    width: 54px;
    height: 62px;
    overflow: hidden;
  }

  .logo-frame img {
    width: 54px;
    height: 62px;
    max-width: 54px;
    max-height: 62px;
    object-fit: contain;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .topbar {
    align-items: stretch;
    grid-template-columns: 1fr;
    gap: 10px;
    min-height: 0;
    padding: 10px 12px;
  }

  .brand {
    display: grid;
    grid-template-columns: 54px 1fr;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }

  .month-controls,
  .quick-controls,
  .view-controls,
  .logo-frame,
  .brand > div:last-child {
    grid-column: auto;
    justify-self: stretch;
  }

  .logo-frame {
    width: 54px;
    height: 50px;
    overflow: hidden;
  }

  .logo-frame img {
    width: 54px;
    height: 50px;
    max-width: 54px;
    max-height: 50px;
    object-fit: contain;
  }

  .brand .eyebrow {
    font-size: 10px;
    line-height: 1.15;
    margin-bottom: 4px;
  }

  h1 {
    font-size: 23px;
    line-height: 1.05;
  }

  h2 {
    font-size: 18px;
  }

  .month-controls {
    grid-template-columns: 46px 1fr 46px;
  }

  .quick-controls {
    grid-template-columns: 1fr 1fr;
  }

  .view-controls {
    grid-template-columns: 1fr 1fr;
  }

  .month-controls button,
  .quick-controls button,
  .quick-controls select,
  .view-controls button,
  .calendar-actions button {
    min-height: 48px;
  }

  .layout {
    gap: 12px;
    padding: 12px;
  }

  .calendar-head,
  .panel-head {
    align-items: stretch;
    padding: 12px;
  }

  .calendar-head {
    flex-direction: column;
  }

  .calendar-actions {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .search-input {
    width: 100%;
  }

  .range-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
    padding: 10px 12px;
  }

  .range-controls button {
    min-width: 0;
    min-height: 46px;
  }

  .day-actions {
    display: grid;
    grid-template-columns: 1fr 48px;
  }

  .day-actions button {
    min-height: 48px;
  }

  .weekdays {
    width: max(760px, 100%);
    min-width: 760px;
    font-size: 12px;
  }

  .calendar-wrap {
    overflow: hidden;
  }

  .calendar-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-color: var(--accent) #101418;
    scrollbar-width: thin;
    touch-action: pan-x pan-y;
  }

  .calendar {
    width: max(760px, 100%);
    min-width: 760px;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    touch-action: pan-x pan-y;
  }

  .calendar-note {
    display: none;
  }

  .mobile-list {
    display: grid;
    border-top: 1px solid var(--line);
  }

  .year-view {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .year-month {
    min-height: 104px;
    padding: 13px;
  }

  .day {
    min-height: 108px;
    padding: 8px;
    touch-action: pan-x pan-y;
  }

  .event-chip {
    min-height: 28px;
    padding: 5px 7px;
    border-left-width: 5px;
    font-size: 13px;
    touch-action: pan-x pan-y;
  }

  .event-chip:nth-of-type(n + 4) {
    display: none;
  }

  .side-panel {
    border-radius: 8px;
    max-height: 76vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .day-list {
    gap: 12px;
    padding: 12px;
  }

  .event-card {
    gap: 8px;
    min-height: 58px;
    padding: 13px;
    font-size: 16px;
  }

  .event-card strong {
    line-height: 1.3;
  }

  .meta {
    font-size: 14px;
  }

  dialog {
    width: calc(100vw - 14px);
    max-height: calc(100vh - 14px);
    padding: 14px;
  }

  input,
  select,
  textarea {
    min-height: 48px;
    font-size: 16px;
  }

  .two-col,
  .dialog-actions {
    grid-template-columns: 1fr;
  }

  .dialog-actions button {
    min-height: 48px;
  }
}

.event-chip.tamamlandi,
.event-card.tamamlandi,
.mobile-event.tamamlandi {
  border-left-color: #9aa4ad;
  border-color: rgba(154, 164, 173, 0.55);
  background: rgba(125, 135, 145, 0.3);
  color: #c8d0d6;
  opacity: 0.72;
  text-decoration: none;
}

.event-card.tamamlandi strong,
.mobile-event.tamamlandi strong {
  color: #c8d0d6;
  text-decoration: none;
}

.event-card.tamamlandi .mini-action.is-active,
.mobile-event.tamamlandi .mini-action.is-active {
  border-color: #c8d0d6;
  background: #c8d0d6;
  color: #071014;
}

.customer-card.tamamlandi {
  border-left-color: #7e8a91;
  background: rgba(126, 138, 145, 0.14);
  color: #c8d0d6;
}

.event-chip.priority-acil,
.event-card.priority-acil,
.mobile-event.priority-acil,
.customer-card.priority-acil {
  border-left-color: var(--cancel);
  background: rgba(255, 114, 114, 0.24);
}

.event-chip.priority-beklemede,
.event-card.priority-beklemede,
.mobile-event.priority-beklemede,
.customer-card.priority-beklemede {
  border-left-color: var(--bekleme);
  background: rgba(255, 179, 71, 0.2);
}
